E
eowen
Picking up this thread from a few years ago. (See below.
I'm in the exact same predicament as David, below. I've tried Jonathan West's suggested workaround of defining an object variable for the BuiltInDocumentProperties collection, but I think I'm finding that you cannot assign to BuiltInDocumentProperties, only read from it
That is, I do the following
dim objBuiltInProps as DocumentPropertie
set objBuiltInProps = ActiveDocument.BuiltInDocumentPropertie
' do some stuff to modify the values of the properties in objBuiltInProp
...
set ActiveDocument.BuiltInDocumentProperties = objBuiltInProp
I get a run-time error on the last line, telling me that the object doesn't support this property or method
Am I doing this wrong, or is there some other way to go about it
For the time being, I'm assigning each property in the objBuiltInProps collection to the corresponding property in ActiveDocument.BuiltInDocumentProperites collection, which causes the whole word count problem to appear again -- Word recounts the words in the document once for each property involved
thank
eowe
-----------------------------------------
Hi David
There are a number of workarounds
1. Define an object variable for the CustomDocumentProperties collection
make your changes to that, and then assign the variable back to th
CustomDocumentProperties collection. This will reduce the number of time
the word count runs to just twice. You can do similar things with th
BuiltInDocumentProperties collectio
2. Drop back to use of the WordBasic object, and use the SetDocumentPropert
method. As MS has not seen fit to properly document the WordBasic object i
VBA Help, the best source of information is the WordBasic Help file fro
Word 95, which I keep handy for just such an occasion
Try thi
WordBasic.SetDocumentProperty "My Property", 0, 2, "My property value
WordBasic command always apply to the ActiveDocument, so beware of this. Th
full entry of SetDocumentProperty is as follow
SetDocumentProperty Name$, Type, Value[$], CustomOrBuiltI
Defines a document property for the active document. If Name$ is a built-i
property that doesn't match the type specified by Type, or if it is
read-only property, an error occurs. Use the DocumentPropertyExists(
function to determine whether a property called Name$ already exists
For a list of the built-in properties available in Word, se
DocumentPropertyName$(). In Word version 6.0, SetDocumentProperty i
unavailable and generates an error
Argument Explanatio
Name$ The name of the property. Name$ can be a built-in property or a custo
property
Type The type of the property to be defined:0 (zero) String1 Number
Date3 Yes or NoIf Name$ is a built-in property and doesn't match the typ
specified by Type, an error occurs
Value[$] The property value. Value[$] must match the type specified b
Type.If Value[$] doesn't match the type specified by Type, an error occurs
CustomOrBuiltIn Specifies whether Name$ is a custom property or a built-i
property:0 (zero) or omitted Name$ is a custom property unless it appear
in the list of built-in properties. If Name$ is a built-in property
SetDocumentProperty will update its value.1 Name$ is a built-in property. I
it is not one of the built-in properties, an error occurs. 2 Name$ is
custom property, regardless of whether a built-in property with the sam
name already exists
3. If you don't mind closing the document first, then you can read and writ
document properties using an ActiveX DLL freely downloadable from th
Microsoft web site. Take a look here for detail
http://www.mvps.org/word/FAQs/MacrosVBA/DSOFile.ht
-
Regard
Jonathan West - Word MV
MultiLinker - Automated generation of hyperlinks in Wor
Conversion to PDF & HTM
http://www.multilinker.co
Word FAQs at http://www.multilinker.com/wordfa
Please post any follow-up in the newsgroup. I do not reply to Word question
by emai
I'm in the exact same predicament as David, below. I've tried Jonathan West's suggested workaround of defining an object variable for the BuiltInDocumentProperties collection, but I think I'm finding that you cannot assign to BuiltInDocumentProperties, only read from it
That is, I do the following
dim objBuiltInProps as DocumentPropertie
set objBuiltInProps = ActiveDocument.BuiltInDocumentPropertie
' do some stuff to modify the values of the properties in objBuiltInProp
...
set ActiveDocument.BuiltInDocumentProperties = objBuiltInProp
I get a run-time error on the last line, telling me that the object doesn't support this property or method
Am I doing this wrong, or is there some other way to go about it
For the time being, I'm assigning each property in the objBuiltInProps collection to the corresponding property in ActiveDocument.BuiltInDocumentProperites collection, which causes the whole word count problem to appear again -- Word recounts the words in the document once for each property involved
thank
eowe
-----------------------------------------
Hi David
There are a number of workarounds
1. Define an object variable for the CustomDocumentProperties collection
make your changes to that, and then assign the variable back to th
CustomDocumentProperties collection. This will reduce the number of time
the word count runs to just twice. You can do similar things with th
BuiltInDocumentProperties collectio
2. Drop back to use of the WordBasic object, and use the SetDocumentPropert
method. As MS has not seen fit to properly document the WordBasic object i
VBA Help, the best source of information is the WordBasic Help file fro
Word 95, which I keep handy for just such an occasion
Try thi
WordBasic.SetDocumentProperty "My Property", 0, 2, "My property value
WordBasic command always apply to the ActiveDocument, so beware of this. Th
full entry of SetDocumentProperty is as follow
SetDocumentProperty Name$, Type, Value[$], CustomOrBuiltI
Defines a document property for the active document. If Name$ is a built-i
property that doesn't match the type specified by Type, or if it is
read-only property, an error occurs. Use the DocumentPropertyExists(
function to determine whether a property called Name$ already exists
For a list of the built-in properties available in Word, se
DocumentPropertyName$(). In Word version 6.0, SetDocumentProperty i
unavailable and generates an error
Argument Explanatio
Name$ The name of the property. Name$ can be a built-in property or a custo
property
Type The type of the property to be defined:0 (zero) String1 Number
Date3 Yes or NoIf Name$ is a built-in property and doesn't match the typ
specified by Type, an error occurs
Value[$] The property value. Value[$] must match the type specified b
Type.If Value[$] doesn't match the type specified by Type, an error occurs
CustomOrBuiltIn Specifies whether Name$ is a custom property or a built-i
property:0 (zero) or omitted Name$ is a custom property unless it appear
in the list of built-in properties. If Name$ is a built-in property
SetDocumentProperty will update its value.1 Name$ is a built-in property. I
it is not one of the built-in properties, an error occurs. 2 Name$ is
custom property, regardless of whether a built-in property with the sam
name already exists
3. If you don't mind closing the document first, then you can read and writ
document properties using an ActiveX DLL freely downloadable from th
Microsoft web site. Take a look here for detail
http://www.mvps.org/word/FAQs/MacrosVBA/DSOFile.ht
-
Regard
Jonathan West - Word MV
MultiLinker - Automated generation of hyperlinks in Wor
Conversion to PDF & HTM
http://www.multilinker.co
Word FAQs at http://www.multilinker.com/wordfa
Please post any follow-up in the newsgroup. I do not reply to Word question
by emai