I have to create a large number of hyperlinks for ticket items where the only part of the URL that changes is the ticket ID. I am new to this and much of the VBA help is for excel. My problem exists in MS-word and its difficult to transfer the syntax.
I expect the user to invoke the macro after entering a 6 digit Ticket ID. Ideally the macro would automatically select the last word typed by the user, and append it to the url segment which never changes.
I attempted to record a macro that copies the last word typed then concatenates it onto the end of the standard URL.
I can successfully do everything with keyboard shortcuts so I thought I would be set. The problem is the macro just uses the text from the recording example. It also turns my text to display to the example text.
Turning any text into the link I used as an example in the recording.
I can't figure out how to make VBA use the copied text for the text to display and the last 6 digits of the URL.
Please see VBA syntax below
Sub textToHyperlink()
'
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
ChangeFileOpenDirectory _
"/Users/chris/Library/Containers/com.microsoft.Word/Data/Library/Preferences/AutoRecovery/"
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"https://someboringwebsite.com/WorkItem&id=123456", SubAddress:="", ScreenTip:="", _
TextToDisplay:="123456"
End Sub