![]() |
|
#1
|
|||
|
|||
![]()
I am looking for some assistance with editing my VBA code. I need a macro that can help me add hyperlinks to time markers in my document.
Here are the steps that the macro needs to accomplish: 1.Ask for meeting ID and allow user input through an inputbox. 2.Find all six-digit numbers (time markers) using the Mid function. 3.Convert the hours, minutes, and seconds obtained from the time markers to integers using the CInt function. 4.Calculate the starting time by multiplying hours by 3600, minutes by 60, and adding them together. 5.Loop through each time marker and add a hyperlink using the ActiveDocument.Hyperlinks.Add code, with the meeting ID and starting time as parameters. Here is the code for the macro: Code:
Sub AddHyperlinksToTimeMarkers() ' Ask for meeting ID Dim mtgID As String mtgID = InputBox("Enter meeting ID") ' Find all six-digit numbers (time markers) Dim timeMarkers As Find Set timeMarkers = ActiveDocument.Range.Find With timeMarkers .ClearFormatting .Text = "[0-9]{6}" .MatchWildcards = True End With ' Loop through each time marker and add hyperlink Do While timeMarkers.Execute ' Get the range of the found text Dim timeMarker As Range Set timeMarker = timeMarkers.Range ' Get hours, minutes, and seconds from time marker Dim hrs As Integer Dim mins As Integer Dim secs As Integer hrs = CInt(Mid(timeMarker.Text, 2, 2)) mins = CInt(Mid(timeMarker.Text, 4, 2)) secs = CInt(Mid(timeMarker.Text, 6, 2)) ' Calculate starting time Dim startTime As Long startTime = hrs * 3600 + mins * 60 + secs ' Add hyperlink to time marker ActiveDocument.Hyperlinks.Add Anchor:=timeMarker, Address:="https://ABC?meetingid=" & mtgID & "&start=" & startTime Loop End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
lalywizz | Word | 5 | 10-08-2021 09:27 AM |
![]() |
arkansawyer16 | Excel | 10 | 04-06-2020 02:03 PM |
![]() |
JellehFishh | Word VBA | 5 | 03-17-2020 02:47 PM |
Regex/wildcard search for dates with 2-digit and 4-digit years | Marrick13 | Word VBA | 2 | 01-29-2016 07:04 AM |
![]() |
laucn | Excel Programming | 14 | 05-17-2015 12:12 PM |