Applescript to insert sound in Microsoft Word

Discussion in 'Mac Programming' started by akiev, Oct 30, 2012.

  1. akiev macrumors newbie

    Oct 30, 2012
    I've spent hours on figuring out how to do this. There is an "API" for inserting images (like make inline picture), but I did not find anything about how to insert a sound into the Word document (2011 Office). Any help will be appreciated. Thanks
  2. kryten2 macrumors 6502a

    Mar 17, 2012
    Looked in the dictionary and could not find anything usable. You can always use UI scripting.

    Example from Dutch version of Word 2011 :

    activate application "Microsoft Word"
    tell application "System Events"
    	tell process "Microsoft Word"
    		-- insert GUI Scripting statements here
    		click menu item "Geluid uit bestand..." of menu 1 of menu item "Audio" of menu 1 of menu bar item "Invoegen" of menu bar 1
    	end tell
    end tell
    on GUIScripting_status()
    	-- check to see if assistive devices is enabled
    	tell application "System Events"
    		set UI_enabled to UI elements enabled
    	end tell
    	if UI_enabled is false then
    		tell application "System Preferences"
    			set current pane to pane id ""
    			display dialog "This script utilizes the built-in Graphic User Interface Scripting architecture of Mac OS x which is currently disabled." & return & return & "You can activate GUI Scripting by selecting the checkbox \"Enable access for assistive devices\" in the Universal Access preference pane." with icon 1 buttons {"Cancel"} default button 1
    		end tell
    	end if
    end GUIScripting_status
    Invoegen = Insert
    Audio = Audio
    Geluid uit bestand... = Sound from file...(not sure about this)
  3. akiev thread starter macrumors newbie

    Oct 30, 2012
    Yes, this is exactly what I'm doing now. But when the sound inserted using UI scripting - it appears in the top left corner, but I need to make it inline with text.

Share This Page