Custom Properties (Word 2007)

L

LA Lawyer

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?
 
J

Jay Freedman

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
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
L

LA Lawyer

Using the numeric constant worked! Thanks.

What are the other numeric constants for the "type" here?
 
J

Jay Freedman

There are five members:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top