There are two different ways of accessing the objects properties in your macro for a word document. The first one is to use the 'ActiveDocument' object and the other one is the 'Documents(filename)' where you have to specify the file name of the word document.
The difference between them is that the ActiveDocument refers to the Document which is active, as the name defines it. The other one refers to a document, with a specific filenanme, whether active or inactive.
If you are working with processing of large documents, it is recommended to use the 'Document(filename)' so that when you switch application windows, the macro will still work on the same document.
Take the following examples below which counts all tables inside the document:
- ActiveDocument.Tables.Count
- Document('c:\testing.doc').Tables.Count
If your active document refers to C:\testing.doc, it will return the same value. But if your active document refers to another document, the values to be returned will not be the same anymore.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment