XL: Macro Does Not Open Report Manager Add-In as Expected

ID: Q132219


The information in this article applies to:
  • Microsoft Excel for Windows 95


SUMMARY

When you run a Visual Basic, Applications Edition, macro that uses the Report Manager add-in and the Report Manager has not previously been opened, the macro runs without error but does not print the report.


MORE INFORMATION

To access a closed Report Manager add-in, open the Report Manager add-in from a Visual Basic for Applications macro, and then use an OnTime function to call a second Visual Basic for Applications macro that runs the Report Manager.

Sample Visual Basic Code

Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.

The following code will print using the Report Manager Add-In even if the Add-In is closed at the time the macros are run:

Sub Test_Print()
Dim LibPath As String
   ' Record the path to the Excel Libraries
   LibPath = Application.LibraryPath & "\REPORTS.XLA"
   ' Open the REPORTS.XLA file.
   Workbooks.Open(Filename:=LibPath).RunAutoMacros _
   Which:=xlAutoOpen

   ' Set up an "OnTime macro that will run the
   ' "Print_Report" macro as soon as the
   ' "Test_Print" macro completes.

   Application.OnTime Now, "Print_Report"
End Sub

Sub Print_Report()
' Report Managers Report.Print should now work correctly.

   Application.ExecuteExcel4Macro String:= _
   "REPORT.PRINT(""TestPrint"",1)"
End Sub 

Additional query words:

Keywords : kbcode kbprg
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: October 22, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.