Sign in to follow this  
Followers 0
Negative1

Resolved:_wordCreate() using color text?

3 posts in this topic

#1 ·  Posted (edited)

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

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