【问题标题】:How to move cursor after a specific word in email body如何在电子邮件正文中的特定单词后移动光标
【发布时间】:2020-07-10 21:08:28
【问题描述】:

我编写了这段代码来将 Outlook 光标向右移动 5 个字:

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

您知道如何在电子邮件正文中的特定单词之后移动鼠标光标吗? 谢谢

【问题讨论】:

    标签: vba outlook ms-word


    【解决方案1】:

    使用Find.Execute method MSDN 找到单词然后移动光标

    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
    

    【讨论】:

      猜你喜欢
      • 2021-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-24
      • 1970-01-01
      • 1970-01-01
      • 2019-06-08
      相关资源
      最近更新 更多