Document Property to display more than 1 line

  • Thread starter Thread starter Alan T
  • Start date Start date
A

Alan T

I added a property 'Address' in a word document and defined a field link
with this property.

I got a string, ie address consists of street name, postcode, state name
separated by a return character.
Is it possible to display the address in several lines?
 
Lene,

While your code appears to work, it seems a bit like driving a tack
with a sledge hammer.

I have used "Replace" build the insert string as follows:

Sub ScratchMacro()
Dim strName As String
Dim strInsert As String
Dim oRng As Range
Set oRange = Selection.Range
strPropName = "Address"
On Error GoTo Err_Handler:
strInsert = ActiveDocument.CustomDocumentProperties(strName).Value
strInsert = Replace(strInsert, "#", Chr(11))
oRng.InsertAfter strInsert
Exit Sub
Err_Handler:
If Err.Number = 5 Then
MsgBox "The docProperty " & Chr(34) & strName & Chr(34) _
& " is not found in this document."
End If
End Sub
 
Hi, thanks for all advices.

The problem is the address string was return from a component, the address
lines are separated by a carriage return key, ie a little vertical
rectangle.

In the Replace function,
what should I put into the "#" ?
 
Select, then use the following macro to identify the character

Sub ANSIValue()
S1$ = "Because the selected text contains"
S2$ = " characters, not all of the ANSI values will be displayed."
S3$ = "ANSI Value ("
S4$ = " characters in selection)"
S5$ = " character in selection)"
S6$ = "Text must be selected before this macro is run."
S7$ = "ANSI Value"
Dim strSel As String
Dim strNums As String
Dim LastFourChar As String
Dim iPos As Integer
strSel = Selection.Text
If Len(strSel) > 0 Then
For i = 1 To Len(strSel)
strNums = strNums + Str(Asc(Mid(strSel, i)))
Next i
strNums = LTrim(strNums)
If Len(strNums) > 255 Then
LastFourChar = Mid(strNums, 252, 4)
strNums = Left(strNums, 251) + Left(LastFourChar, _
4 - InStr(" ", LastFourChar))
MsgBox S1$ + Str(Len(strSel)) + S2$
End If
If Len(strSel) = 1 Then S4$ = S5$
MsgBox strNums, 0, S3$ + LTrim(Str(Len(strSel))) + S4$
Else
MsgBox S6$, 0, S7$
End If
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top