View Single Post
 
Old 12-04-2023, 06:19 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default It does work as it is coded.

Quote:
Originally Posted by RobiNew View Post
Well, that was just a friendly comment! Perhaps you can explain why the code here below doesn't work at all. I want to go to the first page of the document without using Selection. Thanks!
Code:
Dim myRange As Range
Set myRange = ActiveDocument.Content
myRange.Collapse Direction:=wdCollapseStart



RobiNew


Your code does work for what you are telling it to do. After running that code, the range is at the start of the document. Consider:
Code:
Sub ScrahtchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim myRange As Range
Set myRange = ActiveDocument.Content
myRange.Collapse Direction:=wdCollapseStart
myRange.InsertBefore "I'm here."
lbl_Exit:
  Exit Sub
End Sub

If you want to start typing at the start of the document then you have to move the insert point to the start of the document as others have explained.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote