Font formatting

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
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Doug,

It's not clear what you mean by the whole variable, or how you are actually
inserting the data into the Word document. If you can set a Range to the
numbers that you want to form, you can apply the formatting to the .Range
object.

If you were inserting the information into a field { DOCPROPERTY } or {
DOCVARIABLE }, you could add a \* CHARFORMAT switch and then if you apply
the desired formatting to the D of either DOCPROPERTY or DOCVARIABLE, the
data would be displayed with that formatting.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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