Running a Print Preview Excel Macro from Navision

mduck
Member Posts: 8
Has anyone created a print preview macro within Excel and called it from Navision?
When I called the macro, excel shows only the current sheet and the macro does not fire.
I first tried to call a chart print preview macro. Excel never came up and Navision locked up.
So I tried a simple print preview macro of just the data. As mentioned, only the current sheet is displayed.
Other defined macro called within Navision worked as defined except for the print preview.
Any help would be greatly appreciated.
Thanks,
Mike
See code below....
From Report OnPostDataItem()
TempExcelBuffer Record Excel Buffer
FullPath Text 200
Test2 name of the excel Macro
TempExcelBuffer.OpenBook2(FullPath);
TempExcelBuffer.RunMacro('test2');
Functions within Record Excel Buffer
Function OpenBook2
Passed Variable FileName Text 250
IF FileName = '' THEN
ERROR(Text001);
IF NOT EXISTS(FileName) THEN
ERROR(Text003,FileName);
IF NOT CREATE(XlApplication,TRUE) THEN
ERROR(Text000);
XlApplication.Workbooks.Open(FileName);
XlWorkBook := XlApplication.ActiveWorkbook;
Function RunMacro
XlApplication Automation 'Microsoft Excel 9.0 Object Library'.Application
Passed Variable MacroName Text 30
XlApplication.Run(MacroName);
YIELD;
When I called the macro, excel shows only the current sheet and the macro does not fire.
I first tried to call a chart print preview macro. Excel never came up and Navision locked up.
So I tried a simple print preview macro of just the data. As mentioned, only the current sheet is displayed.
Other defined macro called within Navision worked as defined except for the print preview.
Any help would be greatly appreciated.
Thanks,
Mike
See code below....
From Report OnPostDataItem()
TempExcelBuffer Record Excel Buffer
FullPath Text 200
Test2 name of the excel Macro
TempExcelBuffer.OpenBook2(FullPath);
TempExcelBuffer.RunMacro('test2');
Functions within Record Excel Buffer
Function OpenBook2
Passed Variable FileName Text 250
IF FileName = '' THEN
ERROR(Text001);
IF NOT EXISTS(FileName) THEN
ERROR(Text003,FileName);
IF NOT CREATE(XlApplication,TRUE) THEN
ERROR(Text000);
XlApplication.Workbooks.Open(FileName);
XlWorkBook := XlApplication.ActiveWorkbook;
Function RunMacro
XlApplication Automation 'Microsoft Excel 9.0 Object Library'.Application
Passed Variable MacroName Text 30
XlApplication.Run(MacroName);
YIELD;
0
Comments
-
Hi mduck,
I only see this topic from many websites, I know when you call a Macro from Excel file in Oracle, that is Objcet.invoke("file name",Run, Macro), and I read your code, that is Nivasion but not Axapta, do you know how to do it, call Macro from Excel file? any hit and piece code will be very helpfull for me
Thanks
Jesse0 -
Hey Jesse,
Not sure if you are using Navision but if you are,
you can call a Macro from Navision by executing the the following code from any report or form.....ExcelBuffer.OpenBook2(FullPath); ExcelBuffer.RunMacro('test2'); ExcelBuffer.GiveUserControl;
FullPath is the Excel file (full path name) with the macro in the file called test2.
Create new functions in table 370 Excel Buffer. See code below...
Hope this helps....
Mike
Functions within Record Excel BufferFunction OpenBook2 Passed Variable FileName Text 250 IF FileName = '' THEN ERROR(Text001); IF NOT EXISTS(FileName) THEN ERROR(Text003,FileName); IF NOT CREATE(XlApplication,TRUE) THEN ERROR(Text000); XlApplication.Workbooks.Open(FileName); XlWorkBook := XlApplication.ActiveWorkbook; Function RunMacro XlApplication Automation 'Microsoft Excel 9.0 Object Library'.Application Passed Variable MacroName Text 30 XlApplication.Run(MacroName); Yeild;
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions