PC Review


Reply
Thread Tools Rate Thread

How to call a macro from a xlam in a xlsm

 
 
CLDommel
Guest
Posts: n/a
 
      23rd Nov 2009
I am writing an aplpication in VBA in Excel 2007. When i used to call a macro
under excel 2003 I could use: Application.run
"XlaFile.xla!'VBAProject.ModuleName.MacroName"

However when i try to use this construction under Excel 2007 i get the
following error message:

"Cannot run the macro 'XLAFile.xlam!VBAProject.ModuleName.MacroName'. The
macro may not be available in this workbook or all macros may be disabled."

The Macro is standing in the Workbook_Open event of my xlsm file and is
calling an addin with xlam extension.
The xlam file is selected in the add-in list.

Does anybody have an idea how i can solve the problem? Can i continue using
the Excel2003 way under Excel2007 or is the call of an macro out of an add-in
changed under Excel2007
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      23rd Nov 2009
There shouldn't be any difference between 2003/2007 with what you are trying
to do. Looks like you are fully qualifying the path to the macro so all the
more reason why it should work. Unless of course any of workbook, project
(sure it's VBAPoroject!), module or macro names are not quite right.

Try simply
'XLAFile.xlam!MacroName'

If that fails rename the macro and try again. If/when working fully qualify
again.

Oh, and ensure of course that the xlam is really open, you should see it in
project explorer. One more thing, depending on the name of the xlam you
might need to embrace it with apostrophes.

Regards,
Peter T


"CLDommel" <(E-Mail Removed)> wrote in message
news:FA665165-5D3E-4D8D-8947-(E-Mail Removed)...
>I am writing an aplpication in VBA in Excel 2007. When i used to call a
>macro
> under excel 2003 I could use: Application.run
> "XlaFile.xla!'VBAProject.ModuleName.MacroName"
>
> However when i try to use this construction under Excel 2007 i get the
> following error message:
>
> "Cannot run the macro 'XLAFile.xlam!VBAProject.ModuleName.MacroName'. The
> macro may not be available in this workbook or all macros may be
> disabled."
>
> The Macro is standing in the Workbook_Open event of my xlsm file and is
> calling an addin with xlam extension.
> The xlam file is selected in the add-in list.
>
> Does anybody have an idea how i can solve the problem? Can i continue
> using
> the Excel2003 way under Excel2007 or is the call of an macro out of an
> add-in
> changed under Excel2007



 
Reply With Quote
 
CLDommel
Guest
Posts: n/a
 
      24th Nov 2009
I don't get it. I imported the module and it did not work, I recreated the
module and it did not work. I cursed at my pc, at MS and at everything that
was in reach. I again recreated the module. And it works...

Application.run "VBAProject.ModuleName.MacroName" does exactly what is it
supposed to do.

*CLDommel shakes head

Why didn't I start cursing earlier, why did I wait three days before
starting to curse? The only solution I can think of now that it does work is
because my pc is afraid of me now :P

Anyways Peter T thank you for your help eventhough all that was needed was
to scare my computer :P

"Peter T" wrote:

> There shouldn't be any difference between 2003/2007 with what you are trying
> to do. Looks like you are fully qualifying the path to the macro so all the
> more reason why it should work. Unless of course any of workbook, project
> (sure it's VBAPoroject!), module or macro names are not quite right.
>
> Try simply
> 'XLAFile.xlam!MacroName'
>
> If that fails rename the macro and try again. If/when working fully qualify
> again.
>
> Oh, and ensure of course that the xlam is really open, you should see it in
> project explorer. One more thing, depending on the name of the xlam you
> might need to embrace it with apostrophes.
>
> Regards,
> Peter T
>
>
> "CLDommel" <(E-Mail Removed)> wrote in message
> news:FA665165-5D3E-4D8D-8947-(E-Mail Removed)...
> >I am writing an aplpication in VBA in Excel 2007. When i used to call a
> >macro
> > under excel 2003 I could use: Application.run
> > "XlaFile.xla!'VBAProject.ModuleName.MacroName"
> >
> > However when i try to use this construction under Excel 2007 i get the
> > following error message:
> >
> > "Cannot run the macro 'XLAFile.xlam!VBAProject.ModuleName.MacroName'. The
> > macro may not be available in this workbook or all macros may be
> > disabled."
> >
> > The Macro is standing in the Workbook_Open event of my xlsm file and is
> > calling an addin with xlam extension.
> > The xlam file is selected in the add-in list.
> >
> > Does anybody have an idea how i can solve the problem? Can i continue
> > using
> > the Excel2003 way under Excel2007 or is the call of an macro out of an
> > add-in
> > changed under Excel2007

>
>
> .
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      24th Nov 2009
That does happen sometimes, maybe some sort of confused corruption in the
'compiled' state of the project, which is why one of the suggestions I gave
was to rename the macro. Anyway glad cursing it a few times also got it
working!

Regards,
Peter T

"CLDommel" <(E-Mail Removed)> wrote in message
news:529C1ACE-DD21-4CDD-8A2D-(E-Mail Removed)...
>I don't get it. I imported the module and it did not work, I recreated the
> module and it did not work. I cursed at my pc, at MS and at everything
> that
> was in reach. I again recreated the module. And it works...
>
> Application.run "VBAProject.ModuleName.MacroName" does exactly what is it
> supposed to do.
>
> *CLDommel shakes head
>
> Why didn't I start cursing earlier, why did I wait three days before
> starting to curse? The only solution I can think of now that it does work
> is
> because my pc is afraid of me now :P
>
> Anyways Peter T thank you for your help eventhough all that was needed was
> to scare my computer :P
>
> "Peter T" wrote:
>
>> There shouldn't be any difference between 2003/2007 with what you are
>> trying
>> to do. Looks like you are fully qualifying the path to the macro so all
>> the
>> more reason why it should work. Unless of course any of workbook, project
>> (sure it's VBAPoroject!), module or macro names are not quite right.
>>
>> Try simply
>> 'XLAFile.xlam!MacroName'
>>
>> If that fails rename the macro and try again. If/when working fully
>> qualify
>> again.
>>
>> Oh, and ensure of course that the xlam is really open, you should see it
>> in
>> project explorer. One more thing, depending on the name of the xlam you
>> might need to embrace it with apostrophes.
>>
>> Regards,
>> Peter T
>>
>>
>> "CLDommel" <(E-Mail Removed)> wrote in message
>> news:FA665165-5D3E-4D8D-8947-(E-Mail Removed)...
>> >I am writing an aplpication in VBA in Excel 2007. When i used to call a
>> >macro
>> > under excel 2003 I could use: Application.run
>> > "XlaFile.xla!'VBAProject.ModuleName.MacroName"
>> >
>> > However when i try to use this construction under Excel 2007 i get the
>> > following error message:
>> >
>> > "Cannot run the macro 'XLAFile.xlam!VBAProject.ModuleName.MacroName'.
>> > The
>> > macro may not be available in this workbook or all macros may be
>> > disabled."
>> >
>> > The Macro is standing in the Workbook_Open event of my xlsm file and is
>> > calling an addin with xlam extension.
>> > The xlam file is selected in the add-in list.
>> >
>> > Does anybody have an idea how i can solve the problem? Can i continue
>> > using
>> > the Excel2003 way under Excel2007 or is the call of an macro out of an
>> > add-in
>> > changed under Excel2007

>>
>>
>> .
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro not working with XLAM add-in B Bean Microsoft Excel Programming 2 28th Jul 2009 11:46 PM
recover xlsm from xlam bill Microsoft Excel Discussion 1 28th Apr 2009 01:08 PM
Cannot run the macro 'LOOKUP.XLAM!GetLookup CeeBee Microsoft Excel Misc 0 21st Jan 2009 11:15 PM
Macro saved in Xlam format, a permenant button on my commandbar?? POrtfolio Microsoft Excel Crashes 0 18th Jul 2008 04:43 PM
call to macro in xlam from macro in xlsb SteveDB1 Microsoft Excel Programming 1 2nd Jul 2008 11:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:05 PM.