This Axapta job works for me (Axapta 3.0, Excel 2000 on W2K):
static void ADB_ExcelMacro(Args _args)
{
COM xlApp;
;
xlApp = new COM("Excel.Application");
xlApp.Visible(1);
xlApp.Run("MacroTest.xls!TestMacro");
// ...
}
Excel will complain, however, if macro security (tools - macro - security)
is set to medium or high. Additionally, the specified workbook will be
opened by the Run method before the macro is executed, so Excel will give
you the [read only][notify][cancel] dialog box if the workbook is already
open by another Excel instance.
In effect this means you'll have to save and close your workbook before
running any macro on it.
A more elegant solution would probably be to write a VBA ClassModule with
public methods which could then be referenced just like any built-in
object.
Hope this helps..
Amund
Thu, 16 Sep 2004 16:21:43 +0200 skrev Jens Strandberg
<[EMAIL PROTECTED]>:
> Thanks for your reply.
>
> The Excel stuff is set up properly and works just fine, when I run the
> macro
> inside Excel.
>
> However, doing the "Run" on the COM object in Axapta tells me, that this
> cannot be done... :-(
>
> Any additional input ?
>
> Best Regards,
> Jens
>
> -----Oprindelig meddelelse-----
> Fra: Amund [mailto:[EMAIL PROTECTED]
> Sendt: 16. september 2004 14:08
> Til: [EMAIL PROTECTED]
> Emne: Re: [development-axapta] Running Excel macros from Axapta through
> COM ?
>
>
> Inside VBA this would be something like: Application.Run
> "Workbook.xls!Macroname"
>
> From Axapta you can use: <Excel
> COM-object>.Run("Workbook.xls!Macroname");
>
> In general you may do what you want inside the macro recorder in Excel
> (or
> Word, or..) and use the resulting VBA-code almost as-is in Axapta.
>
> Amund
>
>
>
> Thu, 16 Sep 2004 13:50:36 +0200 skrev Jens Strandberg
> <[EMAIL PROTECTED]>:
>
>> Hello there,
>>
>> I am using COM to display data from Axapta in Excel. Is there a way to
>> tell
>> Excel to run a certain macro once the data has been moved to Excel ?
>>
>> Thanks in advance !
>>
>> Best Regards,
>>
>> Jens
>>
>>
>>
>> Yahoo! Groups Sponsor
>> ADVERTISEMENT
>>
>> Yahoo! Groups Links
>>
>> To visit your group on the web, go to:
>> http://groups.yahoo.com/group/development-axapta/
>>
>> To unsubscribe from this group, send an email to:
>> [EMAIL PROTECTED]
>>
>> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/