Share via

AppleScript save as "original" Word document

Anonymous
2013-08-16T14:22:42+00:00

hello,

i have an applescript which also saves the active document. for this i use

[code]

    tell application "Microsoft Word"

        save as active document file name tmpDoc file format format document

    end tell

[/code]

but this doesn't save the file in the same manner as when i choose save as in word as a doc document.

in bash, file myDocumentSavedInWord gives sth like

"CDF V2 Document, Little Endian, Os: Windows, Version 6.1, Code page: 1252, Author: Admin, Template: Normal, Last saved by: "... and so on, lots of informations.

also, for this file the small data icon in finder shows some text as indicating "not en empty document"

when saved with apple script, in bash file myDocumentSavedWithApplescirpt says

Zip archive data, at least v2.0 to extract

i get this result for all documents i save with applescript. however, for some it works out well, but some documents cant be opened after saved with applescript. word says (translated"

"the open xml-file "myDocument" can not be opened because the content causes problems

Details: no errordetails available"

when i save this document from word as doc document i get the "normal" bash file info and everything is okay.

i have no influence of how the word documents are created since they are created from our onlinesoftware as html files.

how can i use applescript to save word documents exactly like word do it when using save as?

thanks

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

3 answers

Sort by: Most helpful
  1. Anonymous
    2013-08-31T00:44:58+00:00

    Over here, the AppleScript code you included above works fine, even from Word-created .htm files.

    In my experience, many files created by external software come across with faulty tables that look OK but behave weirdly in Word (as in being unable to select, delete or resize rows). Furthermore, they often have tables within tables, extremely thin columns used as margins and strange-looking cell borders. Look for problems in that area. Try converting to an intermediate format (.RTF has fixed many of those issues for me), then Save As into the final format.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-08-29T10:11:09+00:00

    oh, it works with format document97!

    i never thought of that because normally one can always save all documents in the new format, although you may not save new documents in the old format

    the document is a normal doc (not docx), why cant i save it in docx within word2011?

    thank you for your help!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-08-17T00:47:12+00:00

    When you specify "format document" in the Save As statement, you are telling Word 2011 to save into its native format, that is, .docx. This is actually a ZIP file, which explains why Bash sees it as such. In fact, if you change the .docx extension to .zip, then right-click to select "Open with" and choose "Archive Utility," it will expand into a new folder.

    To get a file in .doc format, you need to use "format document97" instead of "format document."

    As to why some files do not work, this could happen if you are trying to open a .docx file with an older version of Word (like v.X or 2004), which would use an external Microsoft-supplied file converter. The converter does not work well with "fancy" files that use Word 2011's features not available in older versions.

    Was this answer helpful?

    0 comments No comments