【发布时间】:2018-08-28 01:57:10
【问题描述】:
我们正在尝试修改由 Molecular Device 软件创建的 rtf 文档。 以下是这些文档之一的部分示例:
协议“C:\ALL USERS\Params\Current\2017 Opto Params\0 VoltageClampContinuous.pro”已打开。 C:\ALL USERS\Alan\2018_07_11\2018_07_11_0000.abf 开始于秒表时间 00:19:48。
所以现在 - 我要做的就是自动找到实验日期(在这种情况下 =“2018_07_11_”) 到目前为止,我的 sub 可以找到正确的光标位置,但是如何在 2 个光标位置之间选择文本?
以下是我所拥有的 CursorPosition 语句当然是错误的 - 这是我想要更正的内容。
Sub FindfilenameDate()
txt_prior_to_expDate = "\"
txt_after_expDate = "0000"
With ActiveDocument.Content.Find
.Text = txt_after_expDate
.Forward = True
.Execute
If .Found = True Then
.Parent.Select
Set after_rng = Selection.Range
expDateEnd_cursorPos = after_rng.Start - 1
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
With Selection.Find
.Text = txt_prior_to_expDate
.Forward = False
.Execute
If .Found = True Then
.Parent.Select
Set charBefore_expDate = Selection.Range
expDateStart_cursorPos = charBefore_expDate.Start + 1
End If
End With
End If
End With
'expDate = CursorPosition(expDateStart_cursorPos, expDateEnd_cursorPos)
'MsgBox ("expDate = " & expDate) 'DELETEMSGBOX
End Sub
【问题讨论】:
标签: vba ms-word cursor-position