D
Doug Lumpkin
Very new to VBA and need a quick tip or two.
Here's the situation. I have a macro that pulls info out of the outlook
address book, and then lists contact info at the top of a fax page.
Works no problem, but I would like to be able to change the font of the
phone and the fax number down to 10pt from the 12 default.
Seems like I could do this with: Selection.Font.Size but this changes for
the whole variable, and if I do that I have to split it into two variables
and rerun the GetAddress again. Is there a way I can format in the middle
of a variable, or format post insertion?
Thanks!
--
=-=-=-
Doug
Public Sub InsertAddressFromOutlook()
Dim strCode, strAddress As String
Dim iDoubleCR As Integer
'Set up the formatting codes in strCode
strCode = "<PR_GIVEN_NAME> <PR_SURNAME>" & vbCr
strCode = strCode & "<PR_TITLE>" & vbCr
strCode = strCode & "<PR_COMPANY_NAME>" & vbCr
strCode = strCode & "<PR_POSTAL_ADDRESS>" & vbCr
strCode = strCode & "Ph: <PR_OFFICE_TELEPHONE_NUMBER>" & vbCr
strCode = strCode & "Fx: <PR_BUSINESS_FAX_NUMBER>" & vbCr & " " & vbCr & "
"
strCode = strCode & "Dear <PR_GIVEN_NAME>" & vbCr
'Let the user choose the name in Outlook
strAddress = Application.GetAddress("", strCode, False, 1, , , True, True)
'Eliminate blank lines by looking for two carriage returns in a row
iDoubleCR = InStr(strAddress, vbCr & vbCr)
While iDoubleCR <> 0
strAddress = Left(strAddress, iDoubleCR - 1) & Mid(strAddress, iDoubleCR +
1)
iDoubleCR = InStr(strAddress, vbCr & vbCr)
Wend
'Insert the modified address at the current insertion point
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect
ActiveDocument.FormFields("NameOfFormfield").Result = strAddress
Else
Selection.TypeText strAddress
End If
End Sub
Here's the situation. I have a macro that pulls info out of the outlook
address book, and then lists contact info at the top of a fax page.
Works no problem, but I would like to be able to change the font of the
phone and the fax number down to 10pt from the 12 default.
Seems like I could do this with: Selection.Font.Size but this changes for
the whole variable, and if I do that I have to split it into two variables
and rerun the GetAddress again. Is there a way I can format in the middle
of a variable, or format post insertion?
Thanks!
--
=-=-=-
Doug
Public Sub InsertAddressFromOutlook()
Dim strCode, strAddress As String
Dim iDoubleCR As Integer
'Set up the formatting codes in strCode
strCode = "<PR_GIVEN_NAME> <PR_SURNAME>" & vbCr
strCode = strCode & "<PR_TITLE>" & vbCr
strCode = strCode & "<PR_COMPANY_NAME>" & vbCr
strCode = strCode & "<PR_POSTAL_ADDRESS>" & vbCr
strCode = strCode & "Ph: <PR_OFFICE_TELEPHONE_NUMBER>" & vbCr
strCode = strCode & "Fx: <PR_BUSINESS_FAX_NUMBER>" & vbCr & " " & vbCr & "
"
strCode = strCode & "Dear <PR_GIVEN_NAME>" & vbCr
'Let the user choose the name in Outlook
strAddress = Application.GetAddress("", strCode, False, 1, , , True, True)
'Eliminate blank lines by looking for two carriage returns in a row
iDoubleCR = InStr(strAddress, vbCr & vbCr)
While iDoubleCR <> 0
strAddress = Left(strAddress, iDoubleCR - 1) & Mid(strAddress, iDoubleCR +
1)
iDoubleCR = InStr(strAddress, vbCr & vbCr)
Wend
'Insert the modified address at the current insertion point
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect
ActiveDocument.FormFields("NameOfFormfield").Result = strAddress
Else
Selection.TypeText strAddress
End If
End Sub