Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Changing font color of text in word using Basic macro

Changing font color of text in word using Basic macro

Changing font color of text in word using Basic macro

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???

RE: Changing font color of text in word using Basic macro

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

RE: Changing font color of text in word using Basic macro

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.Insert Heading1$(x)  +Chr$(10) 'inserts text & return

I've tried the following code without success:

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??

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close