VBA macro code to change font text color

vba font color macro , vba , font color macro ms word Yonkers, United States
  • 10 years ago

    Hi I am looking for code to change the font text color in an MS Word document.

    My purpose is to verify that the user has macros enabled. My thought is that the "default" font text color of the document would be all white (EXCEPT one line that says, in black font color, "This document requires macros enabled. Please reopen the document and choose to enable macros"). This would make it appear as if the only thing in the document was just that one sentence. All the other text would be virtually hidden. However, if user initally choose to enable macros when opening the document, all the document text would be changed to black and the sentence about "needing to enable macros" would be changed to white, making it invisible.

  • 10 years ago

    It will probably vary according to the version of Word you are using, but the easiest way is to record a macro and then edit that code. At minimum, you will need to select the text (something like Selection.WholeStory should select all the text in the document) and then change the font color (like Selection.Font.Color = vbBlack)

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Beware of bugs in the above code; I have only proved it correct, not tried it.” - Donald Knuth