Running Code in an XLA from a Worksheet

C

Chrissy

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

TIA.

Chrissy.
 
T

Tom Ogilvy

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.
 
C

Chrissy

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.
 
T

Tom Ogilvy

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

--
Regards,
Tom Ogilvy


Chrissy said:
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
 
T

Tom Ogilvy

Actually, it should be

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

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

Chrissy

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
 

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

Similar Threads


Top