Results 1 to 2 of 2
2005-01-10, 19:21 #1
- Join Date
- Apr 2002
- Wellington, Wellington, New Zealand
- Thanked 0 Times in 0 Posts
Use VBA to make changes to a Read-Only document (VBA/Word XP)
I want to use VBA to make some minor changes to a word document loaded as ReadOnly:
+ updating some Document Properties (as visible through
+ some fields based on those properties (in headers and
footers throught the document).
When we "View" a word document contained by our document management system, the document opens with the ReadOnly property on the Document object set to True.
I have existing VBA code that populates a series of document properties by modifying the CustomDocumentProperties collection that is a part of the Document object. When the Document is ReadOnly, this code still runs, but the properties remain unchanged.
The contents of these document properties are "published" within the document itself by using Fields.
I'm looking for a technique to achieve the following:
+ Update the CustomDocumentProperties collection even though the
Document itself is ReadOnly
+ Update the fields publishing those properties, again even though
the Document itself is ReadOnly
2005-01-10, 19:55 #2
- Join Date
- Dec 2000
- New York, NY
- Thanked 29 Times in 27 Posts
Re: Use VBA to make changes to a Read-Only documen
This seems odd - if a document is set to read-only, you should still be able to make any changes you want to it, including running VBA code to update document properties and related fields, and you should see the resultant changes in the document. The only point at which the read-only property is going to kick in, is when you try to save the document - at which point you should get the Save As dialog appear.
This behavior would be the same, whether you make the changes via code, or manually in Word's user interface.
Perhaps there is some other kind of protection being applied to the document, by the document management system, when it is in View mode - for example, protected for Comments only - in that case, the code would run without error, but there would be no resultant change in the document.
If this were the case, you could programatically remove the document protection, before running the code to update the doc properties and fields.