Share via

Regarding Audio Files in a Word Document

Anonymous
2019-03-24T00:38:34+00:00

Greetings,

I'm currently creating a text document in microsoft word for a student I have that is blind. I would like to add an audio file into my word document that automatically plays upon opening the document.

So far, I've made several attempts to do this, but I'm always missing a component of what I'm trying to achieve.

What I've tried so far:

  1. I've embedded an audio file into the word document by going to Insert > Object > Create from File > audio file. The advantage from this method is that the audio file is in the word document, which means if I send the document to the student, the audio file can still play even if he doesn't actually have the audio file on his local computer. The problem is that I can't figure out a way to make this audio file play automatically when the document opens, you have to double click it, which he can't, since he's blind.
  2. I've tried using the developer tab. Developer > Legacy Tools > More Controls > Windows Media Player > Properties > Audio File. This strategy basically does the opposite of #1. It gives me a media player, it plays the audio file automatically upon opening the document, however, if the local computer doesn't have the audio file on it, it can't play it. Additionally, I tried putting in a URL link to the audio file on youtube, but nothing happened when I did this.

If anyone knows of a way to achieve what I'm trying to do in a word document, it would be very much appreciated. I'm aware that this would most likely be simpler on power point or something, but in this case, I have to do what I can with word.

Thank you for anyone who can assist with this.

Sincerely,

Ron

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Jay Freedman 207.6K Reputation points Volunteer Moderator
    2019-03-24T02:00:32+00:00

    Re-save the Word document containing the embedded object, saving it as a macro-enabled (*.docm) file in a Trusted Location on your computer. Then open the macro editor and double-click the ThisDocument icon in the Project Explorer (on the left) under the Project that has the document's name. In the code window on the right, insert this code:

    Private Sub Document_Open()

        On Error Resume Next

        ActiveDocument.InlineShapes(1).OLEFormat.Activate

    End Sub

    The number 1 in that code assumes that the embedded audio object is the first inline object in the document; if it isn't the first (or only) object, change the number to the correct value. Save and close the document, and then re-open it.

    You'll probably see a prompt asking whether to trust the object, to which you can answer yes and check the box for "don't ask again". The audio file should then play in whatever your default program is for that file type.

    I'm not certain how this will work when you give the document to your student -- whether the same prompt will appear. It should help if the document is stored in a Trusted Location on their computer; at least that will suppress the security checking that could prevent the macro from running.

    Also, be sure to ask the student whether they use assistive technology such as a screen reader. If they do, then prompts and error messages such as those I mentioned won't necessarily be show-stoppers.

    4 people found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Jay Freedman 207.6K Reputation points Volunteer Moderator
    2019-03-24T23:35:43+00:00

    One quick question if you don't mind before you save the next person haha. If I have two audio files that I want to have play automatically, what would be the easiest way to do that? I don't know much about code, but would I just copy the exact code you gave me, put it in again a second time beneath the first block of code, and switch the number from "1" to "2" so that it plays the second audio file?

    Unfortunately, it isn't that easy. If you simply include two Activate statements, one after the other, the first audio file will be immediately interrupted as the second file starts. Also, don't try to include two separate Document_Open macros, as that will simply give an error message of "Ambiguous name detected".

    What will work is to include two Activate statements separated by a Sleep statement. The Sleep function isn't part of Visual Basic for Applications, but is part of every version of Windows. To use it, you place a Declare statement at the beginning of the ThisDocument module as shown below. In the call to Sleep, enter the number of milliseconds (the number of seconds multiplied by 1000) to wait for the first file to finish before starting the second file.

    #If VBA7 Then

    Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    #Else

    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    #End If

    Private Sub Document_Open()

        ActiveDocument.InlineShapes(1).OLEFormat.Activate

        Sleep dwMilliseconds:=30000

        ActiveDocument.InlineShapes(2).OLEFormat.Activate

    End Sub

    (The #If - #Else - #End If structure ensures that the declaration works properly in both 32-bit and 64-bit Office.)

    A note for VBA programmers reading this and wondering why I don't use Application.OnTime: Because the OnTime timer runs in the Word process, it doesn't get executed until the external audio player program terminates. In most cases, that would require the user to manually close it. The goal here is to play the files without any manual actions.

    3 people found this answer helpful.
    0 comments No comments
  2. Charles Kenyon 166.7K Reputation points Volunteer Moderator
    2019-03-24T01:47:29+00:00

    Hi Ron,

    I'm thinking you would be better off using PowerPoint for this rather than Word.

    With Word the recipient will need to have a designated player for the audio file. I can't think of a way to get it to start upon opening the file without a macro. (For that matter, I can't think of how to do it with a macro, but I think it could be done.)

    You can actually embed an audio file in a PowerPoint presentation and have it start when the file is opened, without macros.

    Here is a temporary link to such a powerpoint.

    https://www.dropbox.com/s/9t9b19j6qp8sjng/AudioPPT.pptx?dl=0

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2019-03-24T02:28:46+00:00

    Thank you so much for your post, I honestly didn't expect anyone to go that far to give me a hand with this issue, that was exactly the kind of workaround I was hoping for.

    I really appreciate you taking the time to do that for me!

    One quick question if you don't mind before you save the next person haha. If I have two audio files that I want to have play automatically, what would be the easiest way to do that? I don't know much about code, but would I just copy the exact code you gave me, put it in again a second time beneath the first block of code, and switch the number from "1" to "2" so that it plays the second audio file?

    Thank you so much!

    0 comments No comments