P
Pehr
I have written, by manipulating a recorded macro, the following macro that is
designed to keep the text in a window from moving after inserting a
cross-reference. That to avoid a very annoying behaviour of MS Word to move
the text in a window when a cross-reference is inserted.
The only problem is that the macro only inserts the paragraph number "1".
That is what was picked up form the recorded macro. It is the statement
'ReferenceItem:="1"' that causes that behaviour. I want to change it so that
I can tell the macro which paragraph number to insert the refernce to, e.g.,
by putting up the cross reference menu and then returning the paragraph
number. How is that done?
Here is the macro:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/22/06 by Pehr Jansson July 21 2006
'
currentscroll = ActiveWindow.ActivePane.VerticalPercentScrolled
currentdoc = ActiveWindow.Document
ReferenceItemToInsert =
ActiveWindow.Document.GetCrossReferenceItems(wdRefTypeNumberedItem)
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:="1", _
InsertAsHyperlink:=True, IncludePosition:=False
ActiveWindow.ActivePane.VerticalPercentScrolled = currentscroll
End Sub
designed to keep the text in a window from moving after inserting a
cross-reference. That to avoid a very annoying behaviour of MS Word to move
the text in a window when a cross-reference is inserted.
The only problem is that the macro only inserts the paragraph number "1".
That is what was picked up form the recorded macro. It is the statement
'ReferenceItem:="1"' that causes that behaviour. I want to change it so that
I can tell the macro which paragraph number to insert the refernce to, e.g.,
by putting up the cross reference menu and then returning the paragraph
number. How is that done?
Here is the macro:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/22/06 by Pehr Jansson July 21 2006
'
currentscroll = ActiveWindow.ActivePane.VerticalPercentScrolled
currentdoc = ActiveWindow.Document
ReferenceItemToInsert =
ActiveWindow.Document.GetCrossReferenceItems(wdRefTypeNumberedItem)
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:="1", _
InsertAsHyperlink:=True, IncludePosition:=False
ActiveWindow.ActivePane.VerticalPercentScrolled = currentscroll
End Sub