How to move cursor after a specific word in email body

醉酒当歌 提交于 2021-01-28 08:14:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!