Sign in to follow this  
Followers 0
autosc

word formatting i Microsoft word

3 posts in this topic

i am trying to change font ... and getting error ...

the problem is

$oRng2.Font.Arial = True << not working

$oRng2.Font.Bold = True << works

CODE
$sText1 = " Congratulation ! You have created the document "

$oWordApp = _WordCreate($sFilePathnew, 0, 0)

$oDoc = $oWordApp.ActiveDocument

$oRng1 = $oDoc.Range

$oRng1.InsertAfter ($sText1)& @CR

$iEnd = $oRng1.End

$oRng2 = $oDoc.Range($iEnd-StringLen($sText1), $iEnd)

$oRng2.Font.Arial = True

_WordDocSave($oDoc)

_WordQuit($oWordApp)

Share this post


Link to post
Share on other sites



This should give you a better understanding.

#include <Word.au3>

Const $wdColorBlue = 16711680

$sText1 = " Congratulation ! You have created the document "
$sFilePathnew = @ScriptDir & "\Test.doc"

$oWordApp = _WordCreate ($sFilePathnew, 0, 1)
$oDoc = _WordDocGetCollection ($oWordApp, 0)

$oRng1 = $oDoc.Range
$oRng1.InsertAfter ($sText1 & @CR)
$iEnd = $oRng1.End
$oRng2 = $oDoc.Range (($iEnd - StringLen($sText1)) + 1, $iEnd)

$oFont = $oRng2.Font
With $oFont
    .Bold = True
    .Underline = True
    .Name = "Arial"
    .Size = 20
    .Color = $wdColorBlue
EndWith

_WordDocSave ($oDoc)
_WordQuit ($oWordApp)

Share this post


Link to post
Share on other sites

This should give you a better understanding.

#include <Word.au3>

Const $wdColorBlue = 16711680

$sText1 = " Congratulation ! You have created the document "
$sFilePathnew = @ScriptDir & "\Test.doc"

$oWordApp = _WordCreate ($sFilePathnew, 0, 1)
$oDoc = _WordDocGetCollection ($oWordApp, 0)

$oRng1 = $oDoc.Range
$oRng1.InsertAfter ($sText1 & @CR)
$iEnd = $oRng1.End
$oRng2 = $oDoc.Range (($iEnd - StringLen($sText1)) + 1, $iEnd)

$oFont = $oRng2.Font
With $oFont
    .Bold = True
    .Underline = True
    .Name = "Arial"
    .Size = 20
    .Color = $wdColorBlue
EndWith

_WordDocSave ($oDoc)
_WordQuit ($oWordApp)
It is printing ... but omitts the first tre letters (con) from

$sText1 = " Congratulation ! You have created the document "

WordDocSave ($oDoc) dont worked

_WordDocSaveAs >> works

Big daddy ... formatting functions missing in your UDF ,are you planning

to add this feature ?

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  
Followers 0