My problem is quite simple but I haven't found a solution so far...
I created a form in Access called Form1. In this form, I inserted an "Unbound Object Frame", which is a new macro-enabled Excel worksheet. In the Excel sheet, I create a macro we can call "ExcelMacro".
I want to know how to run macros in this Excel sheet from Access, e.g. in my Access macro, run "ExcelMacro"
I do NOT want to link my Excel sheet to an external Excel workbook.
Do you have any ideas?
Thanks a lot for your help!
Edit:
In case you need some additional information:
Name of Unbound Object Frame: xlObject
OLE Class: Microsoft Excel Macro-Enabled 12
Class: Excel.SheetMacroEnabled.12
Sheet name: Sheet1
You can use the following in Access:
Where "HelloWorld" is the name of the Excel Macro.
GetObject(, "Excel.Application")
gets the latest opened Excel application. This needs to be the Excel application that is running your embedded worksheet. If it's another, it will fail.Also, the worksheet needs to be open, else it will fail (you can add either of the following code segments to open it before running this).
or
To make sure there are no other instances of Excel running, and possibly quit them if they are (note: these make use of runtime errors and error handlers)