Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing font color of text in word using Basic macro

Status
Not open for further replies.

outlet

Programmer
Jun 3, 2005
2
US
Can anyone help with this?? I use hummingbird 6.0 editor, using hummingbird basic. I have a macro that interfaces with billing software, checks port status and prints out the final report in a word doc. I have the word object declared and everything works fine, except I can't change the font color, on specific lines of text, in the final product. Any suggestions???
 
If you're using anything like VBA then try setting a BookMark to the part you want to change fontcolor, then use:

Selection.GoTo what:=wdGoToBookmark, Name:="bm2"
Selection.Font.Color = wdColorRed


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
It's more Basic than VB. Here is how the MS Word object is created:

Dim WBO As Object 'Declare WBO as object
Set WBO = CreateObject("Word.Basic")
WBO.AppShow 'show the word doc
WBO.FileNewDefault 'Default file name assigned by word

The line of text I want to change the font color on is contained in an array called Heading1$():

Heading1$(x) = "ERROR KEY:"

The code that inserts the text into the word doc is:

WBO.FONT "Courier"
WBO.FontSize 12
WBO.FONT "Bold"
WBO.Insert Heading1$(x) +Chr$(10) 'inserts text & return


I've tried the following code without success:

WBO.FONT "Red"
WBO.FontColor "Red" 'this line creates compiler object error

Any ideas???? Anyone?? The Hummingbird Basic Workbench for Windows NT 6.1 editor being used only has options for Font type, style & size. There is no option for color. Do I have to open a specific word document, then kick off an internal macro in that doc to change the font color??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top