MetaPropeties

G

Greg Maxey

Does anyone know how to access the "MetaProperty" object and
"MetaProperties" collection in a Word document. I can run Test1 to get
BuiltInDocumentProperties and Test2 to get CustomDocumentProperties, but
Test3 fails.

Sub Test1()
Dim prop As DocumentProperty
For Each prop In ActiveDocument.BuiltInDocumentProperties
On Error Resume Next
Debug.Print prop.Name & " - " & prop.Value
Next
End Sub

Sub Test2()
Dim prop As DocumentProperty
For Each prop In ActiveDocument.CustomDocumentProperties
On Error Resume Next
Debug.Print prop.Name & " "; prop.Value
Next
End Sub

Sub Test3()
Dim prop As MetaProperty
For Each prop In ActiveDocument.MetaProperties '???????????
On Error Resume Next
Debug.Print prop.Name & " "; prop.Value
Next
End Sub

There is a dearth of information on this object and collection in the VBA
help file. Someone sent me a Word document that had a bunch of metadata
fields (shown using Office Menu>Prepare>Properties "Application Properties -
Server") that where created using SharePoint (know idea what that is). Each
one of these fields has a corresponding entry on Insert>QuickParts>Document
Properties. When I click one a content control is inserted in the document
apparently mapped to this data. The problem is that the data in his
sharepoint server is in currency format and the format of the CC is stripped
of the "$" and "commas." I am trying to figure out how to get access to
these properties programatically to format them.

Thanks.
 
G

Gordon Bentley-Mix

Greg,

First you need to understand a bit about SharePoint. Have a look at "What is
Microsoft Office SharePoint Server?"
http://www.microsoft.com/sharepoint/prodinfo/what.mspx.

I'm not totally familiar with the product myself, but I do understand it has
some document management functions and that it's designed to integrate with
Word "seamlessly". Other EDMS products also make this claim, but I think
SharePoint has an advantage because it's a MSFT product, and, as such, the
developers have access to the guts of Word that third-party vendors don't
have. What this means in practical terms is that SharePoint has the ability
to add stuff to Word documents - in this case, those MetaProperties that
you're trying to work with.

HOWEVER...

I don't think that MetaProperties are actually part of the Word OM, so you
might not be able to do much with them using VBA. It's more likely that the
only full access to these MetaProperties is through SharePoint itself. I know
this is certainly the case with several other EDMS products that I've worked
with: they somehow "tag" the actual .doc file with attributes (metadata) that
only the EDMS can see. In some cases, a tiny bit of this metadata is visible
outside of the EDMS environment, but you can't do anything really useful with
it. (Other, older EDMS products used to use custom document properties or
document variables to store this metadata and employed an "integration"
add-in to provide access to this information, but I think highly-exposed
nature of this method has driven down its popularity - probably because guys
like us were exploiting it like you're trying to do now.)

Anyway, that's my take on the problem. Unless someone with more SharePoint
experience knows differently, you might be SOL mate. Maybe you could post
this question in one of the SharePoint NGs and find some help there.
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
G

Greg Maxey

Gordon,

Thanks.

I am not really interested in getting to know SharePoint or any other
application right now. Someone sent me a document that they had created
with InfoPath and Sharepoint and was asking why when they enter currency
values in the InfoPath application that the corresponding Word (I call them
document properties for lack of a better term and since they are inserted
usign Insert>QuickParts>Document Properties) content controls show only
numerical values (e.g., $5,000.00 entered in InfoPath shows 5000 in the Word
document). I fiddled around with it some and noticed that if I manually
entered $5,000.00 in the CC then it would take on the red dotted border
which means there is a schema violation.

That got me looking for ways to access the actual property to see if I could
some how force a currency format.

The only example in VBA Help for any of the multiple is:

MetaProperties Object
Represents a collection of properties describing the metadata stored in a
document.
Example


In the following example, a MetaProperties object is passed to a validation
function. The function then validates the value of a single property
represented by its index and returns the result.

Visual Basic for Applications
Function ValidateMetaProperty(ByVal metaProps As MetaProperties) As String
Dim result As String

result = metaProps(1).Validate
ValidateMetaProperty = result
End Function

There is nothing that gives even the slightest hint as to how to make this
function work or work with any of the othe metaproperty methods or
attributes: Application, Creator, ID, Parent, Type, Value, etc.

The help leads one to believe that there is a collection of thes things but
no help on how to access them :-(
 
G

Greg Maxey

Gordon,

It looks like I have stumbled on something useful.

Sub Test5()
Dim i As Long
Dim prop As Office.MetaProperty
Dim props As Office.MetaProperties
Set props = ActiveDocument.ContentTypeProperties
i = 1
For Each prop In props
Debug.Print i & ". Type: " & prop.Type & " ID: " & prop.ID _
& " Name: " & prop.Name & " Value: " & prop.Value
i = i + 1
Next prop
End Sub
 
G

Gordon Bentley-Mix

SNAP!

After reading this article

http://msdn.microsoft.com/en-us/library/bb242818.aspx

I was going to suggest that perhaps the MetaProperties you want to work with
could be accessed through the Document.ContentTypeProperties Property. Looks
like you beat me to it though!
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 

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