View Single Post
 
Old 09-30-2020, 08:04 PM
MrConfused MrConfused is offline Windows 10 Office 2010
Novice
 
Join Date: Sep 2020
Posts: 1
MrConfused is on a distinguished road
Default Returning to the pane (and maybe point) that the cursor was when the macro started

I apologize if this is too simple. I'm new at this.

I have a macro that changes all text in the main document, header, and footer to Times New Roman font (see below). At the end, it goes to the end of the main document. I would rather it go back to whatever pane was active when the macro started. Even better would be for it to go back to the exact point the cursor was at when it started. I tried lots of variations on setting dimensions of myvariable to various options, then tried setting myvariable=ActiveWindow.ActivePane.View or ActiveWindow.ActivePane.View.SeekView, etc., then at the end of the macro, ActiveWindow.ActivePane.View.SeekView = myhvariable But whatever specific variable type and syntax I need, I couldn't find. Please help.

Sub TNR()
'
' Change all fonts to Times New Roman
'
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.WholeStory
Selection.Font.Name = "Times New Roman"

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Font.Name = "Times New Roman"

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.WholeStory
Selection.Font.Name = "Times New Roman"

ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.EndOf
End Sub
Reply With Quote