Jump to content
Sign in to follow this  
litlmike

Word COM; How to Set Font Properties

Recommended Posts

litlmike

I have been trying to figure out the solution on MSDN for hours now, with minimal success.

At the end of a Word document, I would like to append some text. While appending, I would like to change the Font properties on some of the text. Specifically, I would like to set some text to the CustomColor: RGB(76,88,46), and change font size to FontSize 9.5. Since I am just appending, if there a way to toggle on/off the font properties, i.e. BoldRun, that solution will work since I can just loop through.

Thanks for any help you can provide.

Local $aWordsWrite1[5] = ["One (1) customized GG Storefront (1 term*) in 1 category             $   [RetailPrice]", _
        "One (1) customized GG Storefront (1 term*) in a 2nd category           $   [Retail-2ndSF]" , _
        "One (1) Company in the Spotlight                       $   [CISPrice]" , _
        "Twelve-Months (12) of FA                   $   [FAPrice]" , _
        "Inclusion (optional) within the GG Network         $           n/c" ]

Local $aWordsWrite2[1] = ["TOTAL VALUE:                             $   [TotalValue]"]

$oWordApp = _WordCreate(@ScriptDir & "\Test.doc", 1, 0)
$oDoc = _WordDocGetCollection($oWordApp, 0)
$oRange = $oDoc.Range

Const $wdStory = 6
Const $wdMove = 0

$oWordApp.Visible = True
$objSelection = $oWordApp.Selection
$objSelection.EndKey ($wdStory, $wdMove)

For $iCC=1 To UBound ($aWordsWrite1)-1
    $objSelection.TypeText ($aWordsWrite1[$iCC])
    $objSelection.TypeParagraph()
Next
$objSelection.TypeParagraph()
$objSelection.BoldRun ;Toggle Bold On/Off

;~ $oText.TextEffect.Font("Courier New")
;~ $objSelection.FontBold(True)
;~ $objSelection.FontBold(True)
;~ $objSelection.TextEffect.FontItalic (True)

For $iCC=0 To UBound ($aWordsWrite2)-1
    $objSelection.TypeText ($aWordsWrite2[$iCC])
    $objSelection.TypeParagraph()
Next
$objSelection.BoldRun ;Toggle Bold On/Off

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.