ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If syntax to test if command button exists (https://www.excelbanter.com/excel-programming/341520-if-syntax-test-if-command-button-exists.html)

mikeburg[_36_]

If syntax to test if command button exists
 

I'm having trouble coming up with the exact syntax for an if statement
to determine if the following command button exists (so code will be
automatically excuted if it does exist):

Application.CommandBars(1).Controls("TestCode")

Any & all help would be greatly appreciated. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=471962


Tom Ogilvy

If syntax to test if command button exists
 
Dim cb as Object
On error resume next
cb = Application.CommandBars(1).Controls("TextCode")
On Error goto 0
if cb is nothing then
' doesn't exist
End if
--
Regards,
Tom Ogilvy

"mikeburg" wrote in
message ...

I'm having trouble coming up with the exact syntax for an if statement
to determine if the following command button exists (so code will be
automatically excuted if it does exist):

Application.CommandBars(1).Controls("TestCode")

Any & all help would be greatly appreciated. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile:

http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=471962





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

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