Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA to trigger a macro assigned to a shape click 1

Status
Not open for further replies.

Fenrirshowl

Technical User
Apr 29, 2003
357
GB
Hi all

We have a spreadsheet provided to us from another company. The VBAProject is protected and I do not know the password.
On worksheet "Main" there is a shape ("Rectangle 2") which has a macro assigned ("ShowInputForm").

We are trying to automate our process with VBA but we have a roadblock in triggering the "ShowInputForm" macro.

I do not know what module the macro is in. I cannot cycle all the VBA components as the VBAProject is protected.

Due to the error message I receive (after trying to simulate the call within a workbook of my own) I suspect the macro may be in the "ThisWorkbook" module.

Application.Run workbookname!macroname
will not work: Run-time error '1004' Cannot run the macro 'workbookname!macroname'. The macro may not be available in this workbook or all macros may be disabled.

Macros are not disabled.

I cannot seem to call the macro directly with VBA, so I was hoping it is possible to simulate the click on the shape. I am struggling to find the appropriate code.

Can anyone assist please?

Thanks in advance

Fen
 
You can try:
Application.Run Workbooks("WorkbookName.xls(m)").Worksheets("WorksheetName").Shapes("Rectangle 2").OnAction
If works, check names in workbookname!macroname. Should be "WorkbookFullName!MacroName".

combo
 
OnAction!

Works a treat. Thanks Combo - I have already burned a number of hours on this.
Brilliant.

Many many thanks

Fen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top