CustomDocumentProperties.Add

M

mbparker

I have a macro that I've built that combines sepearte word documents into
one. The purpose is to allow the second document to be repeated multiple
times based on a number a user provides in an input box. Once the document is
generated we then assign custom doucment properties to the document with data
from form fields in the generated document populating the properties using
boomarks as the link source.

All of the custom properties are set either to be stored with "Type" equal
to text or date. This works fine except several of the properties that should
store as text store the data as number if the data contains only numerics.
For these fields is there something I can do to have the data always store as
text no matter what characters are in form field?

I'm developing in Word 2000 (due to a software conflict with another
application) for users who are in Word 2003. The code I have so far...

Sub PNDCL()

Dim intI As Integer
Dim intLoop As Integer

intI = CInt(InputBox("How many policies do you have"))

Call PNDCL_H
For intLoop = 1 To intI
Call PNDCL_P
Next intLoop

With ActiveDocument
.CustomDocumentProperties.Add Name:="InsuredName",
LinkToContent:=True, Type:=msoPropertyTypeString, LinkSource:="InsuredName"
.CustomDocumentProperties.Add Name:="DateofDeath",
LinkToContent:=True, Type:=msoPropertyTypeDate, LinkSource:="DateofDeath"
.CustomDocumentProperties.Add Name:="WorksheetDate",
LinkToContent:=True, Type:=msoPropertyTypeDate, LinkSource:="WorksheetDate"
.CustomDocumentProperties.Add Name:="NotificationDate",
LinkToContent:=True, Type:=msoPropertyTypeDate, LinkSource:="NotificationDate"
.CustomDocumentProperties.Add Name:="DateofBirth",
LinkToContent:=True, Type:=msoPropertyTypeDate, LinkSource:="DateofBirth"
.CustomDocumentProperties.Add Name:="WFRouter", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="WFRouter"
.CustomDocumentProperties.Add Name:="Policy1", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="Policy1"
.CustomDocumentProperties.Add Name:="Policy2", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="Policy2"
.CustomDocumentProperties.Add Name:="Policy3", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="Policy3"
.CustomDocumentProperties.Add Name:="Policy4", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="Policy4"
.CustomDocumentProperties.Add Name:="Policy5", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="Policy5"
.CustomDocumentProperties.Add Name:="Policy6", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="Policy6"
.CustomDocumentProperties.Add Name:="Policy7", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="Policy7"
.CustomDocumentProperties.Add Name:="Policy8", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="Policy8"
.CustomDocumentProperties.Add Name:="Policy9", LinkToContent:=True,
Type:=msoPropertyTypeString, LinkSource:="Policy9"
.Protect wdAllowOnlyFormFields
End With

End Sub
 

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