AbstractCure
New Member
- Joined
- Sep 11, 2017
- Messages
- 2
Somehow I'm getting Run-time error 438 Object doesn't support this property or method. The code is placed in "ThisWorkbook" in a VBA project in Excel 2016, but I had this issue even Excel 2013 ever since I created this workbook.
Private Sub Workbook_Open()
ActiveWorkbook.Worksheets("User card").Activate
ActiveWorkbook.Worksheets("User card").SearchBox.Activate
End Sub
The idea is to activate a TextBox called "SearchBox" when the Excel file is open. The error happens at the line where SearchBox.Activate is. Also, the error only pops up when the Excel file was previously saved with anything entered in the "SearchBox" text box. If it was saved with a blank SearchBox, then the error doesn't show.
So, I decided to empty the text box before activating it:
Private Sub Workbook_Open()
ActiveWorkbook.Worksheets("User card").Activate
ActiveWorkbook.Worksheets("User card").SearchBox.Text = ""
ActiveWorkbook.Worksheets("User card").SearchBox.Activate
End Sub
... and now I'm getting the same error at the line SearchBox.Text = ""
... but if the workbook was saved with an empty SearchBox, then the error doesn't happen.
Do you have a way of activating a textbox that actually works?
Thank you!
Private Sub Workbook_Open()
ActiveWorkbook.Worksheets("User card").Activate
ActiveWorkbook.Worksheets("User card").SearchBox.Activate
End Sub
The idea is to activate a TextBox called "SearchBox" when the Excel file is open. The error happens at the line where SearchBox.Activate is. Also, the error only pops up when the Excel file was previously saved with anything entered in the "SearchBox" text box. If it was saved with a blank SearchBox, then the error doesn't show.
So, I decided to empty the text box before activating it:
Private Sub Workbook_Open()
ActiveWorkbook.Worksheets("User card").Activate
ActiveWorkbook.Worksheets("User card").SearchBox.Text = ""
ActiveWorkbook.Worksheets("User card").SearchBox.Activate
End Sub
... and now I'm getting the same error at the line SearchBox.Text = ""
... but if the workbook was saved with an empty SearchBox, then the error doesn't happen.
Do you have a way of activating a textbox that actually works?
Thank you!