Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word: Selection Object not "selecting"

Status
Not open for further replies.

MajP

Technical User
Aug 27, 2005
9,382
US
Unable To Select (Highlight) Selection In Word

I have a few procedures where I am trying to select a range. For some reason i get a valid selection object, but the selection does not "select". I get no highlighting of the selection.
Example
Code:
Private foundRange
Public Sub ReplaceTextOnly(strReplace As String)
  If Not foundRange Is Nothing Then foundRange.Text = strReplace
  foundRange.Select
  'For Test purposes
  Debug.Print Selection.Text
  Debug.Print Selection.Start & " " & Selection.End
  Selection.Font.Bold = True
End Sub

The debug.print provides the expected results for the selection object, and the correct range turns bold. So somehow I am getting the correct selection object but it is not showing the "selection.
 
What is the value of the Application.ScreenUpdating property at the time the code does the selection ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks. After some testing it appears to be an automation issue. The issue only happens when the word document is opened the second time. If everything is closed out and run then it works fine. I think it has something to do with fully qualify objects when doing automation. Similar to the remote server not available error .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top