23.05.2008, 18:05 | #1 |
Участник
|
Dynamics AX: Calling an Excel Macro from X++
Источник: http://dynamics-ax.blogspot.com/2008...ro-from-x.html
============== All, recently I needed to know how to call an Excel Macro from X++. This is not something that is widely published anywhere on the web, and something I had to figure out. It's actually not that hard, and the best help was looking at how I had done it before in .Net. So here is the code example: SysExcelApplication ExcelApp; SysExcelWorkbooks WorkBooks; SysExcelWorkbook WorkBook; SysExcelWorksheet Worksheet; ; ExcelApp = SysExcelApplication::construct(); ExcelApp.displayAlerts(true); ExcelApp.visible(true); ExcelApp.workbooks().open("SomeExcelFile.xls"); Workbook = ExcelApp.workbooks().item(1); Worksheet = Workbook.worksheets().itemFromName("WorkSheetName"); ExcelApp.comObject().Run("SomeMacro"); // The Call to run a Macro Of course there is a lot more you can do, but basically any Excel based class has a .comObject() at which you can further extend and make Excel Interop COM calls via, that go beyond what is coded for in the SysExcel Class framework. Check back soon! "Visit the Dynamics AX Community Page today!" Find a job at: DynamicsAXJobs.com, also post a job for only $99.00! ============== Источник: http://dynamics-ax.blogspot.com/2008...ro-from-x.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
26.05.2008, 16:39 | #2 |
Moderator
|
"Давно тут сидим..."
Цитата:
Сообщение от Gustav
Как вариант с минимальными усилиями: можете попробовать запускать из Аксапты вашу VBA-процедуру в первозданном эксельном виде на невидимом эксельном хосте при помощи следующего джоба:
X++: static void Job_CreateNomenclature(Args _args) { COM xlApp, wbks, wbk; ; xlApp = new COM('Excel.Application'); wbks = xlApp.Workbooks(); wbk = wbks.Open(@'C:\YourExcelFile.xls'); xlApp.Run('CreateNomenclature'); } |
|
|
|