Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Reference Tab name to two textboxes | Excel Discussion (Misc queries) | |||
Clear all textboxes on a form ? | Excel Programming | |||
Find textboxes on a form ? | Excel Programming | |||
TextBoxes on a Form | Excel Programming | |||
Form Textboxes | Excel Programming |