Clear a textbox

S

Stuart

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.
 
T

Tom Ogilvy

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 = ""
 
S

Stuart

Value!
Thanks again.

Regards.

Tom Ogilvy said:
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 = ""
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top