I use the VLC HTTP requests
(see https://wiki.videolan.org/VLC_HTTP_requests/).
I start vlc e.g. with following command:
"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I http --http-host=127.0.0.1 --http-port=9090 --http-password=abc "C:\path\to\your\audio.mp3"
In Word I use the following VBA-Code, which I assign to a shortcut key (e.g. F8)
Sub vlc_insert_time()
Dim req As Object
Set req = CreateObject("Microsoft.XMLHTTP")
req.Open "GET", "http://127.0.0.1:9090/requests/status.xml", False
req.SetRequestHeader "Content-Type", "application/json"
req.SetRequestHeader "Accept", "application/json"
req.SetRequestHeader "Authorization", "Basic " + EncodeBase64(StrConv("" + ":" + "abc", vbFromUnicode))
req.Send
resp = req.ResponseText
Dim obj
Set obj = CreateObject("MSXML2.DOMDocument.6.0")
obj.LoadXML (resp)
ts = o.SelectSingleNode("//root/time").text
s = "[" + Format(ts / 3600 / 24, "hh\H:mm\M:ss\S") + "]" ' adapt this to your format
Selection.TypeText s
End Sub
The function Base64Encode
is borrowed from https://stackoverflow.com/a/169945/1659599. I repeat it here for convenience:
Function EncodeBase64(text As String) As String
Dim arrData() As Byte
arrData = StrConv(text, vbFromUnicode)
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")
objNode.dataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64 = objNode.Text
Set objNode = Nothing
Set objXML = Nothing
End Function