autosc Posted January 26, 2007 Share Posted January 26, 2007 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) Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 26, 2007 Moderators Share Posted January 26, 2007 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) Link to comment Share on other sites More sharing options...
autosc Posted January 26, 2007 Author Share Posted January 26, 2007 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 ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now