Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default Excel TextBox Control

I have a textbox named "txt_report_date" inserted in a worksheet called "admin"
When this worksheet is active I can populate the textbox value using the me
syntax, me.txt_report_date = ...
However I would like to set the value of the text box when the workbook opens.
Can you please tell me how to reference the text box from the on open event
of the workbook. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excel TextBox Control

Qualify the object with a reference to the sheet, eg

ThisWorkbook.Sheet1.txt_report_date ' where sheet1 is the codename

But if in any doubt about the sheet and object existing use one of these -

ThisWorkbook.Worksheets("Sheet1").txt_report_date etc

or even -

Dim ole As OLEObject
On Error Resume Next
Set ole = ThisWorkbook.Worksheets("Sheet1").OLEObjects("txt_ report_date")
On Error GoTo 0
If Not ole Is Nothing Then
ole.Object.Value = Format(Now, "dd mmm yyyy")
End If

Regards,
Peter T



"James" wrote in message
...
I have a textbox named "txt_report_date" inserted in a worksheet called
"admin"
When this worksheet is active I can populate the textbox value using the
me
syntax, me.txt_report_date = ...
However I would like to set the value of the text box when the workbook
opens.
Can you please tell me how to reference the text box from the on open
event
of the workbook. Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default Excel TextBox Control

Thanks. That worked great.

"Peter T" wrote:

Qualify the object with a reference to the sheet, eg

ThisWorkbook.Sheet1.txt_report_date ' where sheet1 is the codename

But if in any doubt about the sheet and object existing use one of these -

ThisWorkbook.Worksheets("Sheet1").txt_report_date etc

or even -

Dim ole As OLEObject
On Error Resume Next
Set ole = ThisWorkbook.Worksheets("Sheet1").OLEObjects("txt_ report_date")
On Error GoTo 0
If Not ole Is Nothing Then
ole.Object.Value = Format(Now, "dd mmm yyyy")
End If

Regards,
Peter T



"James" wrote in message
...
I have a textbox named "txt_report_date" inserted in a worksheet called
"admin"
When this worksheet is active I can populate the textbox value using the
me
syntax, me.txt_report_date = ...
However I would like to set the value of the text box when the workbook
opens.
Can you please tell me how to reference the text box from the on open
event
of the workbook. Thanks.



.

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
Rich TextBox Control in excel 2007 K[_2_] Excel Programming 1 June 18th 09 03:48 PM
VBA Excel - Textbox disappearing BEHIND listview control - Zorder is useless. Radu Excel Programming 3 December 7th 05 02:54 PM
How to move cursor from one textbox control to another textbox con Tom Ogilvy Excel Programming 1 September 16th 04 03:42 PM
How to move cursor from one textbox control to another textbox con KMoore007 Excel Programming 0 September 16th 04 02:47 PM
Set Focus Problem for textbox control on multipage control ExcelDeveloperSPR Excel Programming 1 July 16th 04 08:54 PM


All times are GMT +1. The time now is 04:18 PM.

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

About Us

"It's about Microsoft Excel"