From: LA Lawyer on
I am trying to assign CustomProperties from Access 2007. I have all of the
proper references and am able to work on Word documents (otherwise) from
Access VBA. Here is my code:

With Word.ActiveDocument.CustomDocumentProperties
.Add Name = "CaseID", Type:=msoPropertyTypeNumber, Value:=TheCaseID,
LinktoContent:=False
.Add Name = "CaseName", Type:=msoPropertyTypeString, Value:=theCaseName,
LinktoContent:=False
End With

When I run this, Access reports that "variable not defined" when it
encounters "msoPropertyTypeNumber". When I put quote marks around that,
nothing happens.

What am I doing wrong? What is the fix?


From: Jay Freedman on
Technically, the "qualified name" of the constant is
Office.msoPropertyTypeString, so try that. If you still can't get it to
work, go into the Tools > References dialog (in the VBA editor) and make
sure you have checked Microsoft Office <version number> Object Library --
although I don't think you could write a working macro without that
reference.

If all else fails, use the numeric value of the constant, which is 4.

To get more information about any constant, press F2 in the VBA editor to
open the Object Browser, and put the constant's name in the search box and
press Enter. When the constant appears in the main window, look at the
bottom of the window for its numeric value and the collection it belongs to,
in this case

Const msoPropertyTypeString = 4
Member of Office.MsoDocProperties

Whatever prefix you see on the collection, you can use that as the qualifier
on the constant's name.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

LA Lawyer wrote:
> I am trying to assign CustomProperties from Access 2007. I have all
> of the proper references and am able to work on Word documents
> (otherwise) from Access VBA. Here is my code:
>
> With Word.ActiveDocument.CustomDocumentProperties
> .Add Name = "CaseID", Type:=msoPropertyTypeNumber,
> Value:=TheCaseID, LinktoContent:=False
> .Add Name = "CaseName", Type:=msoPropertyTypeString,
> Value:=theCaseName, LinktoContent:=False
> End With
>
> When I run this, Access reports that "variable not defined" when it
> encounters "msoPropertyTypeNumber". When I put quote marks around
> that, nothing happens.
>
> What am I doing wrong? What is the fix?


From: LA Lawyer on
Using the numeric constant worked! Thanks.

What are the other numeric constants for the "type" here?
"Jay Freedman" <jay.freedman(a)verizon.net> wrote in message
news:u7Fee4v5KHA.6052(a)TK2MSFTNGP02.phx.gbl...
> Technically, the "qualified name" of the constant is
> Office.msoPropertyTypeString, so try that. If you still can't get it to
> work, go into the Tools > References dialog (in the VBA editor) and make
> sure you have checked Microsoft Office <version number> Object Library --
> although I don't think you could write a working macro without that
> reference.
>
> If all else fails, use the numeric value of the constant, which is 4.
>
> To get more information about any constant, press F2 in the VBA editor to
> open the Object Browser, and put the constant's name in the search box and
> press Enter. When the constant appears in the main window, look at the
> bottom of the window for its numeric value and the collection it belongs
> to, in this case
>
> Const msoPropertyTypeString = 4
> Member of Office.MsoDocProperties
>
> Whatever prefix you see on the collection, you can use that as the
> qualifier on the constant's name.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup
> so all may benefit.
>
> LA Lawyer wrote:
>> I am trying to assign CustomProperties from Access 2007. I have all
>> of the proper references and am able to work on Word documents
>> (otherwise) from Access VBA. Here is my code:
>>
>> With Word.ActiveDocument.CustomDocumentProperties
>> .Add Name = "CaseID", Type:=msoPropertyTypeNumber,
>> Value:=TheCaseID, LinktoContent:=False
>> .Add Name = "CaseName", Type:=msoPropertyTypeString,
>> Value:=theCaseName, LinktoContent:=False
>> End With
>>
>> When I run this, Access reports that "variable not defined" when it
>> encounters "msoPropertyTypeNumber". When I put quote marks around
>> that, nothing happens.
>>
>> What am I doing wrong? What is the fix?
>
>


From: Jay Freedman on
There are five members:

msoPropertyTypeNumber = 1
msoPropertyTypeBoolean = 2
msoPropertyTypeDate = 3
msoPropertyTypeString = 4
msoPropertyTypeFloat = 5


On Wed, 28 Apr 2010 11:36:42 -0700, "LA Lawyer" <hkapp(a)kapplaw.com>
wrote:

>Using the numeric constant worked! Thanks.
>
>What are the other numeric constants for the "type" here?
>"Jay Freedman" <jay.freedman(a)verizon.net> wrote in message
>news:u7Fee4v5KHA.6052(a)TK2MSFTNGP02.phx.gbl...
>> Technically, the "qualified name" of the constant is
>> Office.msoPropertyTypeString, so try that. If you still can't get it to
>> work, go into the Tools > References dialog (in the VBA editor) and make
>> sure you have checked Microsoft Office <version number> Object Library --
>> although I don't think you could write a working macro without that
>> reference.
>>
>> If all else fails, use the numeric value of the constant, which is 4.
>>
>> To get more information about any constant, press F2 in the VBA editor to
>> open the Object Browser, and put the constant's name in the search box and
>> press Enter. When the constant appears in the main window, look at the
>> bottom of the window for its numeric value and the collection it belongs
>> to, in this case
>>
>> Const msoPropertyTypeString = 4
>> Member of Office.MsoDocProperties
>>
>> Whatever prefix you see on the collection, you can use that as the
>> qualifier on the constant's name.
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the newsgroup
>> so all may benefit.
>>
>> LA Lawyer wrote:
>>> I am trying to assign CustomProperties from Access 2007. I have all
>>> of the proper references and am able to work on Word documents
>>> (otherwise) from Access VBA. Here is my code:
>>>
>>> With Word.ActiveDocument.CustomDocumentProperties
>>> .Add Name = "CaseID", Type:=msoPropertyTypeNumber,
>>> Value:=TheCaseID, LinktoContent:=False
>>> .Add Name = "CaseName", Type:=msoPropertyTypeString,
>>> Value:=theCaseName, LinktoContent:=False
>>> End With
>>>
>>> When I run this, Access reports that "variable not defined" when it
>>> encounters "msoPropertyTypeNumber". When I put quote marks around
>>> that, nothing happens.
>>>
>>> What am I doing wrong? What is the fix?
>>
>>
>