I use Microsoft Office 2003 and create a bunch of template documents to standardize some tasks. I asked about it on Superuser.com and didnโt get an answer, so I think it is too programmatic and I hope that Iโm more lucky.
I need to automate a workflow that uses a bunch of Office templates (mostly Word). I want to have "My Template Foo.dot" and "My Template Bar.dot" etc. In the "My Foo Bar Stuff" on the shared drive and double-click on the template to create a new Foo or Bar.
I would really like for the user to double-click on the Foo template and receive a request for a couple of elements related to their task (for example, the project number) and have a script in the template change name that "Save" will default to "Foo for Project 1234.doc. "
I asked Google Groups and got an answer that worked ... for a while. Then my AutoNew macro stopped when I created a new document by double-clicking on the template. I have no idea why and how to debug it.
In the class modules / this application, I have:
Sub AutoNew() Dim Project As String Project = InputBox("Enter the Project Number") ActiveDocument.SaveAs "Project " & Project & " Notes.doc" End Sub
In Microsoft Word Objects / ThisDocument, I have:
Private Sub Document_New() End Sub
I really donโt know why and where it came from.
In Tools / Macro Security ... I have set the security level to Low.
I am a software developer with over 25 years of experience, but full Office noob automation. Specific solutions and pointers to โthis is how to automate Wordโ are common. Thanks.
Update:. If I create a new template (new ..., "empty document", "Save as" "My New Template.dot") and insert the AutoNew() macro, it works. So what is stopping him from working on my existing template?
Update 2: Removing a module and function from an old template and adding it back also works.