Page 1 of 1

Can I open a .txt file in WORD using a specific Template?

PostPosted: Tue Apr 18, 2023 6:01 am
by MacOCD
Q. Is it possible open a .txt text file (unicode) in WORD using a specific WORD template?

I have a "Headed Paper" Word document template (includes a logo). I regularly need to email the full contents of various text files as a PDF using this template.

My Current workflow:

1/ Open text file in BBEDIT
2/ Ctrl A to select all
3/ Copy
4/ Open Word with the required template
5/ Paste into the New Document
6/ Save the Word Document (to allow later edits if necessary)
7/ Email the Word Document as a PDF

I've got the emailing bit sorted, but it occurs to me there must be a way to script the creation of a Word document using a specific template and insert the text (always the complete text file)

Having done a little research people typically create a new document using a template & script a paste from the clipboard into it. That doesn't seem a reliable solution if emailing automatically, as the contents of the clipboard could get changed by other processes.

Any ideas?

Thanks.

Re: Can I open a .txt file in WORD using a specific Template

PostPosted: Tue Apr 18, 2023 2:13 pm
by Mr_Noodle
This sounds like something for AppleScript.

Re: Can I open a .txt file in WORD using a specific Template

PostPosted: Tue Apr 18, 2023 2:55 pm
by MacOCD
I assume any solution will be AppleScript or Bash script based, when I try to open the text file in Word with AppleScript I get an import screen with options to select. I’m trying to insert the text into a word document based on a specified template.

Re: Can I open a .txt file in WORD using a specific Template

PostPosted: Wed Apr 19, 2023 9:04 am
by Mr_Noodle
That's a bit outside of the support I can give. I suggest checking out some AppleScript sites for help on how to do this.