问题
I wrote this code to move Outlook cursor 5 words to right:
Option Explicit
Public Sub Example()
Dim Inspector As Outlook.Inspector
Dim wdDoc As Word.Document
Dim Selection As Word.Selection
Set Inspector = Application.ActiveInspector()
Set wdDoc = Inspector.WordEditor
Set Selection = wdDoc.Application.Selection
Selection.MoveRight Unit:=wdCharacter, Count:=5, Extend:=wdMove
Set Inspector = Nothing
Set wdDoc = Nothing
Set Selection = Nothing
End Sub
Do you have any idea how to move mouse cursor after a specific word in email body? Thank you
回答1:
Work with Find.Execute method MSDN Find the word then move the cursor
Option Explicit
Public Sub Example()
Dim Inspector As Outlook.Inspector
Dim wdDoc As Word.Document
Dim Selection As Word.Selection
Set Inspector = Application.ActiveInspector()
Set wdDoc = Inspector.WordEditor
Set Selection = wdDoc.Application.Selection
With Selection.Find
.MatchWildcards = False
.Text = "word"
.Execute
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
End Sub
来源:https://stackoverflow.com/questions/60931549/how-to-move-cursor-after-a-specific-word-in-email-body