View Single Post
 
Old 03-04-2016, 03:36 PM
here4singin here4singin is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Mar 2016
Posts: 2
here4singin is on a distinguished road
Default Resolved

^^ see my post above ^^
With dev help, I now have a working macro! Here ya go:

Sub InsertXrefWithPage()
Dim StrNm As String
Dim Dlg As Dialog
Set Dlg = Dialogs(wdDialogInsertCrossReference)
Dlg.InsertAsHyperLink = 1
Dlg.Display
With Selection
Dim CurrentStyle As Style
Set CurrentStyle = .Style
.Start = .Start - 1
.Style = "insertnameofyourstylehere"
If .Fields.Count = 0 Then Exit Sub
StrNm = "PAGE" & LTrim(.Fields(1).Code.Text)
.Collapse wdCollapseEnd
.InsertAfter " (page "
.Style = CurrentStyle
.Collapse wdCollapseEnd
Dim addedField As Field
Set addedField = .Fields.Add(Range:=.Range, Type:=wdFieldEmpty, Text:=StrNm, PreserveFormatting:=False)
.InsertAfter ") "
End With
End Sub

The result is Running with Bears (page 67).
Reply With Quote