#1
|
|||
|
|||
Text box- text color
I've got a macro, which inserts a text box with a symbol(text) in it. The color of the symbol is Black-(R,G,B)-0,0,0. I want to make it Red-(R,G,B)- 255,0,0. There are two options to achieve this. First by altering the color from black to red and second by changing the initial color. The main difficulty for me is to recognize which part of the macro script deals with the symbol(text) color. Do you have any suggеstions?
Code:
Sub InsertTB() Dim Shp As Shape Set Shp = ActiveDocument.Shapes.AddTextbox(1, fcnXCoord, fcnYCoord, 288, 72) With Shp .TextFrame.TextRange.InsertSymbol Font:="+Body", CharacterNumber:=9679, Unicode:=True .Line.Visible = msoFalse .Fill.Visible = msoFalse .Width = 155# .Height = 62# End With Set Shp = Nothing End Sub Function fcnXCoord() As Double fcnXCoord = Selection.Information(wdHorizontalPositionRelativeToPage) End Function Function fcnYCoord() As Double fcnYCoord = Selection.Information(wdVerticalPositionRelativeToPage) End Function |
#2
|
||||
|
||||
It's a characteristic of the font in the text range e.g.
Code:
With .TextFrame.TextRange .InsertSymbol Font:="+Body", CharacterNumber:=9679, Unicode:=True .Font.ColorIndex = wdRed End With
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
[IMG][/IMG]
|
#4
|
|||
|
|||
Code:
With Shp With .TextFrame.TextRange .InsertSymbol Font:="+Body", CharacterNumber:=9679, Unicode:=True .Font.ColorIndex = wdRed End With .Line.Visible=msofalse . . .
__________________
Backup your original file before doing any modification. |
#5
|
||||
|
||||
You didn't copy what I posted, so no wonder it doesn't work. Font is an attribute of the text range not of the shape.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#6
|
|||
|
|||
[IMG][/IMG] [IMG][/IMG]
|
#7
|
||||
|
||||
You still haven't implemented the code as advised...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
|||
|
|||
[IMG][/IMG]
|
#9
|
|||
|
|||
On the first place my gratitude goes to gmayor for supplementing the script, then to eduzs for digging into details and finally to macropod for his confirmation that I'm on a wrong track. *** I decided to take my chances and first changed the CharacterNumber from 9679(symbol=dot) to 9632 (symbol=square) then highlighted the symbol with a yellow color. To my great surprise it worked. However, it is hard to believe that, this time I've made things right at the first attempt. I need your final approval of the edited script.
Last edited by BLUEPUPIL; 04-14-2018 at 02:02 AM. |
#10
|
|||
|
|||
[IMG][/IMG]
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Advanced Font Color Manipulation In Word: Inserting another color than the surrounding text | stuartg | Word | 1 | 02-20-2017 12:38 AM |
Text Field [content control] - Default text color vs Filled Text color | jackcoletti | Word | 3 | 02-01-2017 08:10 AM |
VBA Word - Find Text Font Color - Insert New Text | jc491 | Word VBA | 2 | 01-04-2016 05:42 PM |
Remove white text background (keeping the font color and page color intact | cc3125 | Word | 1 | 10-26-2015 06:44 PM |
Macro to search warning text style and replace the text color | rohanrohith | Word VBA | 3 | 11-27-2014 01:08 PM |