Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Converting .docx to .dotx is there a script/automator somewhere?

I need to transfer a larger number of documents from .docx to .dotx.  I was hoping to find a script somewhere but have not been able to find one.  Does anybody know of such a script/automator?  Or another fast way to do so?

 

PS I will need the same for Excel and PowerPoint, but figured that once I had one for one I can change this to work for the others.

Posted on May 31, 2020 5:45 AM

Reply
Question marked as Best reply

Posted on May 31, 2020 11:31 AM

Try this:

on open theDroppedItems
	repeat with a from 1 to length of theDroppedItems
		set theCurrentDroppedItem to item a of theDroppedItems
		tell application "Microsoft Word"
			activate
			open theCurrentDroppedItem
			set theActiveDoc to the active document
			save as theActiveDoc file format format template
			close theActiveDoc
		end tell
		tell application "Finder"
			set name extension of theCurrentDroppedItem to "dotx"
		end tell
	end repeat
end open


Create a new document in Script Editor using the above content. Save as an application. Drop Word document onto it and they will be converted to document templates.


You should know that I'm not a fan of AppleScript. This has exhausted by AppleScript knowledge.

12 replies
Question marked as Best reply

May 31, 2020 11:31 AM in response to ChangeAgent

Try this:

on open theDroppedItems
	repeat with a from 1 to length of theDroppedItems
		set theCurrentDroppedItem to item a of theDroppedItems
		tell application "Microsoft Word"
			activate
			open theCurrentDroppedItem
			set theActiveDoc to the active document
			save as theActiveDoc file format format template
			close theActiveDoc
		end tell
		tell application "Finder"
			set name extension of theCurrentDroppedItem to "dotx"
		end tell
	end repeat
end open


Create a new document in Script Editor using the above content. Save as an application. Drop Word document onto it and they will be converted to document templates.


You should know that I'm not a fan of AppleScript. This has exhausted by AppleScript knowledge.

Jun 1, 2020 6:34 AM in response to etresoft

I am now in the same room as the machine.  I ran your script and it does everything one could wish for.  A big thank you!

 

I thought it would be a simple thing to make it work in Excel and in PowerPoint.  Just change two aspects of a line. Unfortunately, it is not.  Do you have a solution?

 

See the pics I enclosed for the challenge it pops up when I try to compile it. 




May 31, 2020 7:16 AM in response to ChangeAgent

You would need to use Word, Excel, and Powerpoint to export their respective docx/xlsx/pptx document formats to the comparable dotx/dotm/xltx/xltm/potx/potm template files. The m is macro-enabled template formats. The AppleScript scripting dictionary for each application may hold a clue as how this is done, if it supports exporting to templates. I do not have Microsoft Office installed, so can go no further with this.

May 31, 2020 8:35 AM in response to VikingOSX

VikingOSX wrote:

You would need to use Word, Excel, and Powerpoint to export their respective docx/xlsx/pptx document formats to the comparable dotx/dotm/xltx/xltm/potx/potm template files.


I knew that.


The m is macro-enabled template formats.

what you mean with this?


The AppleScript scripting dictionary for each application may hold a clue as how this is done, if it supports exporting to templates.

it might and I was hoping it exist somewhere out there...

Jun 1, 2020 4:36 AM in response to ChangeAgent

ChangeAgent wrote:

Morning Etresoft.

Thanks for this.

I am not at the machine running Office365 so cannot test. However if I understand your script correctly (and I am not a AS expert) it will only change the type from .docx to .dotx. Is this correct?

Isn’t that specifically what you asked for?

If so, this seems to work under 201, but it does not under 365 for mac.

You mean Office 2011? No clue. I only tested this on Office 365.

Jun 1, 2020 5:17 AM in response to etresoft

etresoft wrote:


ChangeAgent wrote:
I am not at the machine running Office365 so cannot test. However if I understand your script correctly (and I am not a AS expert) it will only change the type from .docx to .dotx. Is this correct?

Isn’t that specifically what you asked for?


Yes indeed for 365. However that Mac is not always where I am (well it is me moving around not the Mac), so that is indeed what my question is about - OS10.15 running 365. So as soon as the Mac and I are in the same building testing will commence. 


If so, this seems to work under 201, but it does not under 365 for mac.
You mean Office 2011? No clue. I only tested this on Office 365.


As your script looked like it only changes the document type, I commented that this would work under 2011 (indeed, typo) but that this does not work under 365.  I did not want to imply you should test it under 2011.

Jun 1, 2020 7:46 AM in response to ChangeAgent

Sorry, I wasn't joking about my AppleScript skills. Hopefully someone else will come along with the right answer. This is just AppleScript in a nutshell. You will have to open the Microsoft Excel dictionary in Script Editor and try different combinations of "save as" and/or "save workbook as" to try to replicate the same behaviour. I just tried several versions, but I couldn't get the same result. It is a trial and error programming language. You can't just figure out the syntax. It's gibberish.

Converting .docx to .dotx is there a script/automator somewhere?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.