ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear a textbox (https://www.excelbanter.com/excel-programming/303866-clear-textbox.html)

Stuart[_5_]

Clear a textbox
 
I cannot find a way to clear the contents of an
ActiveX textbox.
Here is what I would like to say:

Sub ClearTextbox()
Dim oleObj As OLEObject

For Each oleObj In ActiveWorkbook.Sheets _
("Contract Master Order").OLEObjects
If TypeOf oleObj.Object Is MSForms.TextBox Then
If oleObj.Name = "Control 1" Then
With oleObj
'clear the contents
End With
End If
End If
Next

Would appreciate help, please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.718 / Virus Database: 474 - Release Date: 09/07/2004



Tom Ogilvy

Clear a textbox
 
Sub ClearTextbox()
Dim oleObj As OLEObject

For Each oleObj In ActiveWorkbook.Sheets _
("Contract Master Order").OLEObjects
If TypeOf oleObj.Object Is MSForms.TextBox Then
If oleObj.Name = "Control 1" Then
With oleObj
.Object.Value = ""
End With
End If
End If
Next


or just

ActiveWorkbook.Sheets("Contract Master Order") -
.OLEObjects("Control 1").Object.Value = ""


--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I cannot find a way to clear the contents of an
ActiveX textbox.
Here is what I would like to say:

Sub ClearTextbox()
Dim oleObj As OLEObject

For Each oleObj In ActiveWorkbook.Sheets _
("Contract Master Order").OLEObjects
If TypeOf oleObj.Object Is MSForms.TextBox Then
If oleObj.Name = "Control 1" Then
With oleObj
'clear the contents
End With
End If
End If
Next

Would appreciate help, please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.718 / Virus Database: 474 - Release Date: 09/07/2004





Stuart[_5_]

Clear a textbox
 
Value!
Thanks again.

Regards.

"Tom Ogilvy" wrote in message
...
Sub ClearTextbox()
Dim oleObj As OLEObject

For Each oleObj In ActiveWorkbook.Sheets _
("Contract Master Order").OLEObjects
If TypeOf oleObj.Object Is MSForms.TextBox Then
If oleObj.Name = "Control 1" Then
With oleObj
.Object.Value = ""
End With
End If
End If
Next


or just

ActiveWorkbook.Sheets("Contract Master Order") -
.OLEObjects("Control 1").Object.Value = ""


--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I cannot find a way to clear the contents of an
ActiveX textbox.
Here is what I would like to say:

Sub ClearTextbox()
Dim oleObj As OLEObject

For Each oleObj In ActiveWorkbook.Sheets _
("Contract Master Order").OLEObjects
If TypeOf oleObj.Object Is MSForms.TextBox Then
If oleObj.Name = "Control 1" Then
With oleObj
'clear the contents
End With
End If
End If
Next

Would appreciate help, please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.718 / Virus Database: 474 - Release Date: 09/07/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.718 / Virus Database: 474 - Release Date: 09/07/2004




All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com