View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Reference to free-form textboxes

There are two textboxes you could use.

One is on the drawing toolbar and one is on the Control toolbox toolbar.

If you try adding a checkbox (manually) from each toolbar, you'll see that the
one from the drawing toolbar is named like: Text box 1 (with a spaces)

And the one from the control toolbox toolbar is named like: Textbox1 (no
spaces)

Option Explicit
Sub testme()

Dim xlApp As Application
Set xlApp = Excel.Application

'to change the value in the textbox from the control toolbox toolbar
xlApp.ActiveWorkbook.Worksheets(1).TextBox1.Value = "hi"

'to change the value in the textbox from the Drawing toolbar
xlApp.ActiveWorkbook.Worksheets(1).TextBoxes("text box 1").Caption = "bye"

End Sub


Krygim wrote:

I insert a text box into Sheet1 of Excel and want to assign a value to this
text box via Excel automation from another program. I have tried the
following syntax without success:
oExcel.ActiveWorkbook.Sheets(1).Textboxes("TextBox 1").Value="Some
Text"

What is the correct syntax (or object path) to refer to this text box?

Thanks in advance.
KM


--

Dave Peterson