ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running Code in an XLA from a Worksheet (https://www.excelbanter.com/excel-programming/279302-running-code-xla-worksheet.html)

Chrissy[_4_]

Running Code in an XLA from a Worksheet
 
I have a button on a worksheet and want it to run code in
an XLA - how do I do this?

TIA.

Chrissy.



Tom Ogilvy

Running Code in an XLA from a Worksheet
 
Use a button from the forms toolbar and then right click on it and choose
assign macro

MyXLA.xls!MyMacro

You will have to type it in.


Assumes the XLA is open.

--
Regards,
Tom Ogilvy

Chrissy wrote in message
...
I have a button on a worksheet and want it to run code in
an XLA - how do I do this?

TIA.

Chrissy.





Chrissy[_4_]

Running Code in an XLA from a Worksheet
 
Thanks.

I was trying to do something like this.

Sub CommandButton1_Click()
Dim XLAFound As Boolean
Dim i As Integer

XLAFound = False

For i = 1 To AddIns.Count
If AddIns(i).Name = "DaySheet.xla" Then
XLAFound = True
End If
Next

If XLAFound Then
AddIns("DaySheet.XLA").Installed = True
Else
AddIns.Add(Filename:=ThisWorkbook.Path & "/" & "DaySheet.XLA", CopyFile:=True).Installed = True
End If

Application.ExecuteMacro "DaySheet.XLA!Module1!showdataentryform"
End Sub

And attaching it to the button - which of course, does not work. I was trying to call the macro
from code so I could make sure the XAL was loaded first. Is this possible?


Chrissy.



"Tom Ogilvy" wrote in message ...
Use a button from the forms toolbar and then right click on it and choose
assign macro

MyXLA.xls!MyMacro

You will have to type it in.


Assumes the XLA is open.

--
Regards,
Tom Ogilvy

Chrissy wrote in message
...
I have a button on a worksheet and want it to run code in
an XLA - how do I do this?

TIA.

Chrissy.







Tom Ogilvy

Running Code in an XLA from a Worksheet
 
Application.Run "DaySheet.XLA!Module1!showdataentryform"

--
Regards,
Tom Ogilvy


Chrissy wrote in message
...
Thanks.

I was trying to do something like this.

Sub CommandButton1_Click()
Dim XLAFound As Boolean
Dim i As Integer

XLAFound = False

For i = 1 To AddIns.Count
If AddIns(i).Name = "DaySheet.xla" Then
XLAFound = True
End If
Next

If XLAFound Then
AddIns("DaySheet.XLA").Installed = True
Else
AddIns.Add(Filename:=ThisWorkbook.Path & "/" & "DaySheet.XLA",

CopyFile:=True).Installed = True
End If

Application.ExecuteMacro "DaySheet.XLA!Module1!showdataentryform"
End Sub

And attaching it to the button - which of course, does not work. I was

trying to call the macro
from code so I could make sure the XAL was loaded first. Is this

possible?


Chrissy.



"Tom Ogilvy" wrote in message

...
Use a button from the forms toolbar and then right click on it and

choose
assign macro

MyXLA.xls!MyMacro

You will have to type it in.


Assumes the XLA is open.

--
Regards,
Tom Ogilvy

Chrissy wrote in message
...
I have a button on a worksheet and want it to run code in
an XLA - how do I do this?

TIA.

Chrissy.









Chrissy[_4_]

Running Code in an XLA from a Worksheet
 
Thanks

Tom Ogilvy wrote
Application.Run "DaySheet.XLA!Module1!showdataentryform"




Tom Ogilvy

Running Code in an XLA from a Worksheet
 
Actually, it should be

Application.Run "DaySheet.XLA!Module1.showdataentryform"

Didn't notice you you had a ! between the module and macro names.

--
regards
Tom Ogilvy

Chrissy wrote in message
...
Thanks

Tom Ogilvy wrote
Application.Run "DaySheet.XLA!Module1!showdataentryform"






Chrissy[_4_]

Running Code in an XLA from a Worksheet
 
Oops - me either - that was a typo.

I even read your post the way you meant to write it and not what
you wrote.

Chrissy.


Tom Ogilvy wrote
Actually, it should be

Application.Run "DaySheet.XLA!Module1.showdataentryform"

Didn't notice you you had a ! between the module and macro names.

--
regards
Tom Ogilvy

Chrissy wrote in message
...
Thanks

Tom Ogilvy wrote
Application.Run "DaySheet.XLA!Module1!showdataentryform"









All times are GMT +1. The time now is 10:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com