Jump to content

Resolved:_wordCreate() using color text?


Recommended Posts

Hi All,

#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc", 0, 0)
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.insertAfter ("This is some text to insert.")

$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.insertAfter ("This is some color text to insert.")

So basically the above code I want to display two lines the first in default font/color and second in another color. I would also be happy if I could make the second line bold instead of color...

Is this possible?

Thanks,

-1

Edit1: Thanks Smartee!

Edited by Negative1

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Link to comment
Share on other sites

hi -1,

Try this:

#include <Word.au3>
$oWordApp = _WordCreate(@ScriptDir & "\Test.doc", 1)
$oDoc = _WordDocGetCollection($oWordApp, 0)
$oDoc.Range.insertAfter("This is some text to insert. ")
$oDoc.Range.insertAfter("This is some text to make bold. ")
$oDoc.Range.insertAfter("This is some text to make red. ")
$mySentence = $oDoc.Sentences(2)
$mySentence.Font.Bold = True
$mySentence = $oDoc.Sentences(3)
$mySentence.Font.Color = 0x0000FF

You can explore MSDN: Microsoft Office Development if you want to do magical stuff with the application objects provided by Microsoft Office. :>

Hope this helps, :unsure:

-smartee

Link to comment
Share on other sites

  • 5 months later...

Where in the MSDN web page do I find the properties of the object that is created :

$mySentence = $oDoc.Sentences(2)

$mySentence.Font.Color = 0x0000FF

Here you have the property to change the color of the text. I actually need the property to aling the text.

Thanks

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...