Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2023, 09:22 AM
loklokpanda loklokpanda is offline Word Macro: How to automatically add hyperlinks to timestamp texts? Windows 10 Word Macro: How to automatically add hyperlinks to timestamp texts? Office 2019
Novice
Word Macro: How to automatically add hyperlinks to timestamp texts?
 
Join Date: Feb 2023
Posts: 1
loklokpanda is on a distinguished road
Default Word Macro: How to automatically add hyperlinks to timestamp texts?

Hi community, Is it possible to automatically add hyperlinks to timestamp texts?



I have a document, which contains a table with 4 columns. The first columns had already filled in timestamps. E.g., 000000 to 000120. And I have a private video uploaded to youtube, which is a recorded meeting. How to write the macro that can automatically add hyperlinks to the timestamps texts?

For example, speaker 1 made his/her speeches from 00:00 to 01:35, and speaker 2 made his/her speeches from 01:36 to 02:00. The youtube URL had already been inserted in the Macro, then it first read the timestamp texts at each cell, and add "&t=_m_s" in that youtube URL according to the timestamp it read.

The below macro can automatically add hyperlinks to text "[1]", "[2]", "[3]" etc. But it cannot add hyperlinks according to the timestamp texts:

Code:
Sub HyperlinkReferences()

Application.ScreenUpdating = False
Dim ReferenceSection As String
Dim rng As Range

ReferenceSection = ""

Dim ref(1 To 3) As String
ref(1) = ""
ref(2) = ""
ref(3) = ""

For i = 1 To UBound(ref) 'i = 1 to number of references
    Selection.HomeKey wdStory
    
    Selection.Find.ClearFormatting
    With Selection.Find
        If ReferenceSection <> "" Then
            .Text = "[" & ReferenceSection & "." & i & "]"
        Else
            .Text = "[" & i & "]"
        End If
        '.Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
    End With
    
    While Selection.Find.Execute
        If Selection.Hyperlinks.Count > 0 Then
            Selection.Hyperlinks(1).Delete
        End If
        If ref(i) <> "" Then
            Set rng = Selection.Range
            rng.SetRange Start:=rng.Start + 1, End:=rng.End - 1
            Selection.Hyperlinks.Add Anchor:=rng, _
            TextToDisplay:=Mid(Selection.Range.Text, 2, Len(Selection.Range.Text) - 2), _
            Address:=ref(i)
        End If
    Wend
Next i

Application.ScreenUpdating = True
End Sub
Since we can link to a specific part in a YouTube video by editing the URL like this:

(Using "The Phantom of the Opera - Emmy Rossum, Gerard Butler" as an example)

URL start from 00:00 - https://www.youtube.com/watch?v=pgz6PnHkmpY
URL specifically starts at 1:30 - https://www.youtube.com/watch?v=pgz6PnHkmpY&t=1m30s

If I typed Gerard Butler as speaker 10, he sings "inside my mind" at 0130. So one of the cells in the first column filled in 0130. The expected macro can read "0130" and add "t=1m30s" after the URL, then add this hyperlink to the "0130" timestamp texts in the document.

If the above cannot be done by macro, is it possible that I type in all timestamp texts in an Excel file first (e.g., 0130), then change the cell's format shown as "h"m"mm"s", then add &t=before the timestamp texts. Add all these to the URL in Excel. Then all specific time URL is completed. Thereby using a macro to add hyperlinks according to this excel?

Your help would be greatly appreciated.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Drive shared file links in WORD 365 - Automatically create hyperlinks displaying Doc names vwq47 Word 0 11-12-2020 08:13 PM
Word Macro: How to automatically add hyperlinks to timestamp texts? VBA/Macro & Allowing Multiple Hyperlinks Per Character/Word JustAboutNoon Word VBA 1 04-10-2015 11:27 PM
Word Macro: How to automatically add hyperlinks to timestamp texts? Microsoft word 2007 - is there a way to automatically turn links into hyperlinks? steveharris Word 2 03-13-2015 10:44 PM
How to set style automatically for specific texts ragesz Word 2 07-25-2013 07:08 AM
Clickable Links Converted to hyperlink texts automatically when I open a word doc Kingsly Word 2 09-13-2012 10:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft