ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trying to create VBA script to run Report Manager function. (https://www.excelbanter.com/excel-programming/287925-trying-create-vba-script-run-report-manager-function.html)

Ken Berg

Trying to create VBA script to run Report Manager function.
 
I am trying to create a VBA script (macro) that will
allow me to run a report manager function from a button
on a spreadsheet.

I recorded a macro of running the report manager function
and received this for code:

Application.ExecuteExcel4Macro String:="Report
Manager"
Application.ExecuteExcel4Macro String:="Report
Manager"
Application.ExecuteExcel4Macro String:= _
"REPORT.PRINT(""Profit and Loss Report
Bundle"",1)"

I then put this code in the buttons on click event and
try to run it but nothing happens.

If I run the report manager function from the menu first
and then run the macro via the push button all works as
expected.

In the doc on the ExecuteExcel4Macro function I found the
statement:

The Microsoft Excel 4.0 macro isn't evaluated in the
context of the current workbook or sheet. This means that
any references should be external and should specify an
explicit workbook name. For example, to run the Microsoft
Excel 4.0 macro "My_Macro" in Book1 you must use "Book1!
My_Macro()". If you don't specify the workbook name, this
method fails.


This leads me to believe that I need to tell the
functions where they are coming from. I have tried every
syntax that I can think of and am not able to resolve
this issue.

Any help would be appreciated (as you probably can tell
by the way I refer to things VBA is not my strong suite).

TIA...



All times are GMT +1. The time now is 02:42 AM.

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