Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event' Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
Go Back  Xtreme Visual Basic Talk > > > > Mimic a Form Control Click 'event'


Reply
 
Thread Tools Display Modes
  #1  
Old 04-18-2017, 08:01 AM
MillMimic a Form Control Click 'event' Mill is offline
Ultimate Contributor

Retired Moderator
* Guru *
 
Join Date: Feb 2000
Location: Michigan, USA
Posts: 2,636
Default Mimic a Form Control Click 'event'


I am working on code to populate a customer form. On the worksheet are some Form buttons (not Command Buttons/oleobjects) that do simple code such as inserting rows if you need to add more items than are initially displayed.

I would like to simulate clicking these buttons through VBA code. Ordinarily, I would do something like:
Code:
Application.Run "myWorkbook.xlsm!RunButtonCode"
Where RunButtonCode is the macro that the creator assigned to the button. However, the VBA code is locked and hidden, so I get an error trying to run the above code.

Let me reiterate - these are not Command Buttons, so I can't just do MyButton_Click. There are no VB events tied to the button - only the macro assigned to it.

I have run across a Buttons object that, I think, may be a legacy type object inherited from earlier versions, but I haven't figured out how to invoke a Click event on it.

I can access the buttons via the Shape event, but Shapes don't have a Click event either.

Does anyone have any advice? It sure seems like it should be simple. Just simulate a button click on a worksheet. No big deal... or not.
__________________
"The face of a child can say it all, especially the mouth part of the face." - Jack Handey
Reply With Quote
  #2  
Old 04-18-2017, 08:28 PM
Kluz's Avatar
KluzMimic a Form Control Click 'event' Kluz is offline
Sapience.Aquire

Super Moderator
* Expert *
 
Join Date: Oct 2003
Location: Lake Bluff, Ill., U.S.
Posts: 3,431
Default

Code:
Application.Run Sheet1.Shapes(1).OnAction
Replace MS's generic sheet name with yours. You can replace the 1 with the button's name in quotes if you want.
__________________
No the other right mouse click
Reply With Quote
  #3  
Old 04-19-2017, 06:16 AM
MillMimic a Form Control Click 'event' Mill is offline
Ultimate Contributor

Retired Moderator
* Guru *
 
Join Date: Feb 2000
Location: Michigan, USA
Posts: 2,636
Default

Quote:
Originally Posted by Kluz View Post
Code:
Application.Run Sheet1.Shapes(1).OnAction
Replace MS's generic sheet name with yours. You can replace the 1 with the button's name in quotes if you want.
Thank you! I do know the names of all of the buttons - I could basically access everything about them but couldn't figure out how to "click" them.

I knew it had to be simple.

Thanks again, Kluz. I wasn't sure how many people still hung around this old Excel area - it doesn't seem to get a lot of action these days.

~Andy
__________________
"The face of a child can say it all, especially the mouth part of the face." - Jack Handey
Reply With Quote
Reply

Tags
buttons, code, event, click, button, form, object, macro, assigned, simulate, command, worksheet, vba, simple, run, type, inherited, tied, events, legacy, advice, deal, shapes, figured, versions


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event' Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event' Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
 
Mimic a Form Control Click 'event'
Mimic a Form Control Click 'event'
 
-->