Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 05-12-2021, 05:16 PM
Guessed's Avatar
Guessed Guessed is offline Playing an audio file from word Windows 10 Playing an audio file from word Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Note also that with the file paths in your example, one included a space and one didn't. Shell commands require the path with spaces to include quotes around it whereas paths without spaces don't NEED the quote marks included. If your actual paths to mp3 files include a space then you will need the quote marks included AND you will need another way to split the strings from the MacroButton
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 



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 an audio file from word 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
Playing an audio file from word Audio not auto playing... TJSNO PowerPoint 5 12-10-2011 12:01 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:03 AM.


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