Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File properties custom field values 1

Status
Not open for further replies.

phessup

Programmer
May 8, 2002
15
US
A packaged software application is using MS Word to generate sales contract documents. It is like a mail merge except instead of reading an external data file to populate the varible data like a standard mail-merge, the application runs an SQL query to return field values that then populate custom document properties fields (that have been created in the template). These now populated values then appear on word document that gets created.

I want to do some conditional testing on the values to use select alternate phrasing, but am unable to do so at execution time using the property fields as I would be able to do if I were using mail-merge data fields.

I need some help with the VBA needed to interrogate the values of the custom fields AFTER they have been populated by the controlling software application at execution time.

Thanks for your help!
 
Interrogating the Custom Document Properties is easy enough. Add a function such as:


Public Function GetPropValue(strPropName as string) as string

on error resume next

Dim custProp

for each custprop in activedocument.customdocumentproperties
if custprop.name = strPropName then
GetPropValue = custprop.value
end if
Next custprop

end function


Then you can simply pass the custom document property name to the function to retrieve the value Eg:

GetPropValue("Author")

you can then compare your value to determine which action to take

However only you will be able to introduce this to your application as we have no way of knowing when the fields are populated - that is something you will have to step through yourself to find.

Hope this helps

Asjeff.......

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top