Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Reference to free-form textboxes

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Reference to free-form textboxes

Hi

I assume that the workbook holding the textbox is the active workbook.

oExcel.ActiveWorkbook.Sheets(1).TextBox 1.Value="Some Text"

Regards,

Per

"Krygim" skrev i en meddelelse
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Reference to free-form textboxes

oExcel.ActiveWorkbook.Sheets(1).TextBox1.Value="So me Value"


"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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Reference to free-form textboxes

Hi Joel and Per,

Thanks for your response. I tried the following command in the Immediate
window of Excel:
ActiveWorkbook.Sheets(1).TextBox1.Value="Some Value"

I got the error message: "Method or data member not found"
I have already named "Text Box 1" as "Textbox1"

But the following command was okay:
ActiveWorkbook.Sheets(1).Range("A1").Value="Some Value"

Any idea?

KM


"Joel" wrote in message
...
oExcel.ActiveWorkbook.Sheets(1).TextBox1.Value="So me Value"


"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


  #5   Report Post  
Posted to microsoft.public.excel.programming
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


  #6   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Reference to free-form textboxes

Hi Dave,

Thanks for your syntax. It works like a charm!

KM


"Dave Peterson" wrote in message
...
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference Tab name to two textboxes AOU Excel Discussion (Misc queries) 5 December 8th 06 09:57 AM
Clear all textboxes on a form ? SpookiePower Excel Programming 1 January 26th 06 04:02 PM
Find textboxes on a form ? SpookiePower Excel Programming 4 January 15th 06 12:50 PM
TextBoxes on a Form Neil Excel Programming 4 June 4th 04 01:25 PM
Form Textboxes Pat[_11_] Excel Programming 1 February 3rd 04 09:42 PM


All times are GMT +1. The time now is 12:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"