Hi, I created a word document using excel vba as shown in the code. I wanted to check if the textbox value is equal to a certain value then I change its font color
Sub addtxtbox ()
Dim wdApp as new word. Application
Dim text as string
Dim doc as word. Document
Dim shp as word. Shape
With wdapp
.activate
.visible = true
Set doc = .documents.add
End with
Set shp= doc.shapes.add(msohorizontalorientation,100,100,20,20)
Set txt=shp.textframe.textrange.text
Txt ="C"
'Check textbox value
If txt= "C" then
shp.textframe.textrange.font.colorindex =wdblue
End if
End sub
The line of code that add textbox and add text to it worked well but the line after 'Check textbox value didn't work.
I went ahead to determine the length of the textbox text using
Debug.print len(shp.textframe.textrange.text)
I got answer as 2
So am wondering what is this other value?
I went further to create a textbox manually then went ahead to print the lenght of the textbox value. I still got 2 and I had just added a single digit.
What is this other value? Kindly assist
Sub addtxtbox ()
Dim wdApp as new word. Application
Dim text as string
Dim doc as word. Document
Dim shp as word. Shape
With wdapp
.activate
.visible = true
Set doc = .documents.add
End with
Set shp= doc.shapes.add(msohorizontalorientation,100,100,20,20)
Set txt=shp.textframe.textrange.text
Txt ="C"
'Check textbox value
If txt= "C" then
shp.textframe.textrange.font.colorindex =wdblue
End if
End sub
The line of code that add textbox and add text to it worked well but the line after 'Check textbox value didn't work.
I went ahead to determine the length of the textbox text using
Debug.print len(shp.textframe.textrange.text)
I got answer as 2
So am wondering what is this other value?
I went further to create a textbox manually then went ahead to print the lenght of the textbox value. I still got 2 and I had just added a single digit.
What is this other value? Kindly assist