I recently posted a message about scripting with Microsoft Word. Well, I’ve played with it some, but no matter what I do, I seem to get the same error message in Word: “Ambiguous name detected: TmpDDE”
I even tried as simple as this:
tell application "Microsoft Word"
activate
open "some:file:out:there:file.doc"
do Visual Basic " Selection.WholeStory"
end tell
…and still the same story.
Does anyone know what this error means, or how to fix it? Thanks for any help
…interesting. I quit Word, and tried the above script. It worked like it should. :?
I think that error will still come up, so if you can offer any help I’d appreciate it.
This may or may not apply to you because you didn’t post more of your code but… You’ll hit some problems when running multi-line VBA scripts that contain hard returns from within AppleScript in Mac OS X. This is because AS in Mac OS X converts those hard returns to Unix line endings, not traditional Mac line endings like Word is expecting and this causes some problems for the Word VBA parser.
When you send a VBA script to Word from AS (do Visual Basic “the VBA code”…), it creates a temp macro to run the VBA code (TmpDDE) and with the error I mentioned above, it will cause this temp file to parse incorrectly and it won’t be flushed since the script is not run to completion. The next time you send a VBA script, even if it doesn’t contain a hard return, because the temp file wasn’t flushed, you’ll probably still get an error. This will continue until you quit Word entirely which would explain the results you were getting.