Thread: InputBox error
View Single Post
 
Old 05-11-2022, 10:17 PM
brownees brownees is offline Windows 10 Office 2021
Novice
 
Join Date: May 2022
Location: Tauranga, New Zealand
Posts: 8
brownees is on a distinguished road
Default InputBox error

Why am I getting a "Command failed" error with the following macro? It doesn't like ReferenceItem:="PhotoNum"


Sub PhotoCrossReference()
'Inserts cross reference to photo number input by user

Dim PhotoNum As Integer
PhotoNum = InputBox("Insert photo number", "Photo cross-reference", "1")

'Output cross reference
Selection.InsertCrossReference ReferenceType:="Photo", ReferenceKind:= _
wdOnlyLabelAndNumber, ReferenceItem:="PhotoNum", InsertAsHyperlink:=False, _
IncludePosition:=False, SeparateNumbers:=False, SeparatorString:=" "

End Sub
Reply With Quote