Application.Run "[TemplateName].[ModuleName].[MacroName]

G

greg

Hello,
I am trying to call a sub in a module in an XLA from a regular excel
document.

I would like to pass along the
Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)

Action to the xla

So if my XLA is called Foo
And the module is called bar
How can I do this
I have tried the following

In the worksheet:

Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
Application.Run "foo.bar.Workbook_SheetBeforeDoubleClick", Sh, Target,
Cancel
End Sub

which does not work

also tried just
Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
Application.Run "Workbook_SheetBeforeDoubleClick", Sh, Target, Cancel
End Sub



In my XLA the sub in the module is:
Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
<<my code>>
End Sub



however I never see the call coming into the XLA


Any ideas?

thanks
 
J

Jim Rech

You just need the name of the workbook (with extension) and the macro:

Application.Run "Book1.xls!RunMe"

--
Jim
| Hello,
| I am trying to call a sub in a module in an XLA from a regular excel
| document.
|
| I would like to pass along the
| Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target
| As Range, Cancel As Boolean)
|
| Action to the xla
|
| So if my XLA is called Foo
| And the module is called bar
| How can I do this
| I have tried the following
|
| In the worksheet:
|
| Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target
| As Range, Cancel As Boolean)
| Application.Run "foo.bar.Workbook_SheetBeforeDoubleClick", Sh, Target,
| Cancel
| End Sub
|
| which does not work
|
| also tried just
| Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target
| As Range, Cancel As Boolean)
| Application.Run "Workbook_SheetBeforeDoubleClick", Sh, Target, Cancel
| End Sub
|
|
|
| In my XLA the sub in the module is:
| Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target
| As Range, Cancel As Boolean)
| <<my code>>
| End Sub
|
|
|
| however I never see the call coming into the XLA
|
|
| Any ideas?
|
| thanks
|
|
|
|
 
G

greg

So you mean
Application.Run "foo.xla.bar.Workbook_SheetBeforeDoubleClick", Sh, Target,
 
J

Jim Rech

This works for me:

Run "WorkbookWithExtension!ModuleName.SubName", Sh, Target, Cancel

--
Jim
| So you mean
| Application.Run "foo.xla.bar.Workbook_SheetBeforeDoubleClick", Sh, Target,
|
|
| | > You just need the name of the workbook (with extension) and the macro:
| >
| > Application.Run "Book1.xls!RunMe"
| >
| > --
| > Jim
| > | > | Hello,
| > | I am trying to call a sub in a module in an XLA from a regular excel
| > | document.
| > |
| > | I would like to pass along the
| > | Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
| > Target
| > | As Range, Cancel As Boolean)
| > |
| > | Action to the xla
| > |
| > | So if my XLA is called Foo
| > | And the module is called bar
| > | How can I do this
| > | I have tried the following
| > |
| > | In the worksheet:
| > |
| > | Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
| > Target
| > | As Range, Cancel As Boolean)
| > | Application.Run "foo.bar.Workbook_SheetBeforeDoubleClick", Sh,
| > Target,
| > | Cancel
| > | End Sub
| > |
| > | which does not work
| > |
| > | also tried just
| > | Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
| > Target
| > | As Range, Cancel As Boolean)
| > | Application.Run "Workbook_SheetBeforeDoubleClick", Sh, Target,
Cancel
| > | End Sub
| > |
| > |
| > |
| > | In my XLA the sub in the module is:
| > | Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
| > Target
| > | As Range, Cancel As Boolean)
| > | <<my code>>
| > | End Sub
| > |
| > |
| > |
| > | however I never see the call coming into the XLA
| > |
| > |
| > | Any ideas?
| > |
| > | thanks
| > |
| > |
| > |
| > |
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top