I have to store company details (name, addresses, telephones, etc) in the custom properties.
Is it possible to store paragraph mark/line feed characters in them?
The idea is that I would have three custom property fields, each containing name, addresses and telephone details. I am hoping to use this field as an array to extract the relevant company information based on the user selection and insert it in a document. Obvioulsy, the address will be 3/4 lines.
For example, custom property fields
CNAMES= ABCD ;EFGH; ;MNOP ;etc.
CADDRESSES=1 View Street,(line feed)Duke Lane,(line feed)Suffolk;27 North Priory,(line feed)London;12 the lane,(line feed)NY;etc.
CTELEPHONES=0893030303030303 ;039383773737373773 ;7487438743873487 ;etc.
Thanks.
Robie
Storing details in custom properties
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
Re: Storing details in custom properties
The above may be confusing so how about this. We would have multiple of these name/address for each location for the compnay. The reason for doing this is that the user selects the location and it update the company information in the document - simple. The reason for having it in the custom properties field is that we can change the content if e.g. the telephone number changes for a particular location (i.e. we don't have to change the code in the template).Robie wrote:I have to store company details (name, addresses, telephones, etc) in the custom properties.
Is it possible to store paragraph mark/line feed characters in them?
The idea is that I would have three custom property fields, each containing name, addresses and telephone details. I am hoping to use this field as an array to extract the relevant company information based on the user selection and insert it in a document. Obvioulsy, the address will be 3/4 lines.
For example, custom property fields
CNAMES= ABCD ;EFGH; ;MNOP ;etc.
CADDRESSES=1 View Street,(line feed)Duke Lane,(line feed)Suffolk;27 North Priory,(line feed)London;12 the lane,(line feed)NY;etc.
CTELEPHONES=0893030303030303 ;039383773737373773 ;7487438743873487 ;etc.
Thanks.
Robie
Store this in a custom property so that all we do is display the custom property as a field on the document.
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78629
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Storing details in custom properties
You can do so in VBA code:
Code: Select all
Sub SetProperty(strName As String, strValue As String)
Dim prp As DocumentProperty
On Error GoTo ErrHandler
Set prp = ActiveDocument.CustomDocumentProperties(strName)
prp.Value = strValue
Exit Sub
ErrHandler:
If Err = 5 Then
Set prp = ActiveDocument.CustomDocumentProperties.Add _
(Name:=strName, LinkToContent:=False, _
Type:=msoPropertyTypeString, Value:="")
Resume Next
End If
End Sub
Sub Test()
SetProperty "CADDRESSES", "1 View Street," & vbCrLf & "Duke Lane," & vbCrLf & "Suffolk"
End Sub
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
Re: Storing details in custom properties
HansV wrote:You can do so in VBA code:
Code: Select all
Sub SetProperty(strName As String, strValue As String) Dim prp As DocumentProperty On Error GoTo ErrHandler Set prp = ActiveDocument.CustomDocumentProperties(strName) prp.Value = strValue Exit Sub ErrHandler: If Err = 5 Then Set prp = ActiveDocument.CustomDocumentProperties.Add _ (Name:=strName, LinkToContent:=False, _ Type:=msoPropertyTypeString, Value:="") Resume Next End If End Sub Sub Test() SetProperty "CADDRESSES", "1 View Street," & vbCrLf & "Duke Lane," & vbCrLf & "Suffolk" End Sub
Thanks Hans, that is exactly what I wanted.