【问题标题】:Word 2010 / 2013 VBA - set selection to be that of a named rangeWord 2010 / 2013 VBA - 将选择设置为命名范围的选择
【发布时间】:2014-12-22 03:59:46
【问题描述】:

我在网上搜索了如何执行一项简单任务的结果。 选择命名范围。我不断得到命名范围内文本的重复,而不是选择。带有 cmets 的代码:

Sub SetSelectionFromRange()
' Goal: Set current selection to be that of a named range
' text of doc is "One Two" and at start the insertion bar is between "w" and "o"
    Dim myRange4 As Range
    Set myRange4 = ActiveDocument.Range(Start:=0, End:=3)
    Selection.Range = myRange4.Duplicate        
' result expected is "One" selected and no change in text
' result actual is "One TwOneo" and insertion bar left after "w" (no selection)`
End Sub

【问题讨论】:

    标签: vba ms-word range selection


    【解决方案1】:

    代替:

    Selection.Range = myRange4.Duplicate
    

    试试:

     myRange4.Select
    

    【讨论】:

    • 完美。对我来说太简单和明显了。非常感谢祖马
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    • 2014-12-17
    • 1970-01-01
    • 2019-10-25
    • 1970-01-01
    相关资源
    最近更新 更多