1

I made a .dot template with a few macros. However, when I create a new document based on the template I run into trouble. If I reference activedocument, I get the message that no document is open. So how do I select part of the new document?

I've tried activedocument.range, me.content.range, me.range, in all cases I either get an error message like property does not exist or no active document, or Word crashes. I'm using Word 2010, but the documents will be saved as .doc for compatibility with another program, and the macros in the template should work in Word 2007 as well.

1 Answer 1

1

Answering my own question since I found a solution/workaround.

I moved the macros to a module (from thisdocument), and that solved the problem. Now I can use activedocument.

For future reference, if you need to access a new document based on a template from a macro stored in thisdocument in the template (such as document_new), you need to embed the code in a new sub in a module in the template.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .