Textbox value

LAWS

New Member
Joined
Dec 23, 2019
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
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
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,214,798
Messages
6,121,635
Members
449,043
Latest member
farhansadik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top