#1
|
||||
|
||||
Playing an audio file from word
Is there a way, perhaps using some sort of hyperlink, to open and play an audio file from a certain position in that file?
So when we click on this link file "blalblah" begins playing at 2 minutes, 32 seconds. Maybe I need some external library? Thanks to all in advance! Susan |
#2
|
||||
|
||||
If it is a hyperlink to a youtube video the start point can be included in the url by adding code at the end of the string. For example "&t=20s" added to the youtube url makes the video start 20 seconds in.
Where is your audio file coming from?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
||||
|
||||
Playing an audio file
All files are on my local desktop, Windows 10 system
|
#4
|
||||
|
||||
I don't know much about this but I would guess that to solve this you would need to specify which media player is your default audio file player. If it is going to be possible, your media player will need to be able to take information passed in from Word.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
||||
|
||||
Ok now what
After some quick research, I have been able to learn how to open I file with VLC player.
Now I haven't programmed in VB for years so I would like to a little lazy and ask for some coaching here: I have built a macro that looks like this: Shell "C:\Program Files\VideoLAN\VLC\vlc --start-time=33.4 C:\test1.mp3" Now all I have to do is: put the subject in the first cell of a two-cell wide table In the left cell the subject: BlahBlah In the right cell the path of the field and the time stamp where to start. C:\test1.mp3 33.4 So now: By clicking on the right cell, get the text of that cell which will be the name of the file and the time to start, and then build the command line and run the macro. But how? And is this the most efficient way to go about it?? Thank for all and any help! Susan Last edited by RRB; 05-12-2021 at 09:01 AM. Reason: mistake |
#6
|
||||
|
||||
Have a look at this page for clues on using Shell commands in a vba macro. https://www.myonlinetraininghub.com/vba-shell#:~:text=The VBA Shell function runs, known as the Command Prompt.
As for getting the contents of a cell into the macro you create, I would supply the text in a macrobutton by pressing Ctrl-F9 to create a field and then type this inside those braces { MacroButton PlayVLC C:\test1.mp3 33.4 } You can then press F9 to show the result and double click it to run the macro. A macro that works by being kicked off by such a macrobutton should work along these lines. Note that I don't have VLC player on my machine so I can't fully test that your syntax works. Code:
Sub PlayVLC() Dim sCmd As String, sArray() As String, vShell sArray = Split(Trim(Selection.Fields(1).Code), " ") Debug.Print sArray(3), sArray(2) sCmd = """C:\Program Files\VideoLAN\VLC\vlc""" & " --start-time=" & sArray(3) & " " & sArray(2) Debug.Print sCmd vShell = Shell(sCmd, vbNormalFocus) End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Playing an audio file from word | RRB | Word | 1 | 05-10-2021 03:13 AM |
audio stops playing after i view the presentation once | Purnima | PowerPoint | 0 | 05-28-2018 02:16 AM |
Playing audio across ALL slides | pixeltaker | PowerPoint | 1 | 09-10-2015 08:27 PM |
Playing only a part of a big audio file with the Hipertextual link | cethai | Word | 4 | 01-03-2015 06:12 AM |
Audio not auto playing... | TJSNO | PowerPoint | 5 | 12-10-2011 12:01 PM |