PDA

View Full Version : Solved: Call an AddIn - Compile Error



Rampant Lion
11-06-2010, 03:17 PM
I am new to VBA, userforms and AddIns and need help. I have Excel 2003. I am trying to develop a userform that users can select the input files they want to process, then launch the addin, which will process them. I keep getting a: 'Compile Error: Sub or Function not defined' and need help to get this to work.

I have attached the userform file...and apparently cannot attach more than 1 file. The AddIn is TestAddinCall.xla, which started as a .xls file and I ran code to save it as an addin in C:\Documents and Settings\Jay\ApplicationData\Microsoft\AddIns. In the attached file, I selected this addin to be linked to this VBAProject. Thanks in advance for your help...

Jay

mdmackillop
11-06-2010, 03:57 PM
Welcome to VBAX

You seem to have a sub named the same as the add-in. I don't think this is correct.
Call TestAddinCall(strTest1, strTest2, strTest3)
AddIns("TestAddinCall").Installed = True
You can call a macro (mytest in this example) in your add-in using Application.Run as here
Public Sub TestQBModule(strTest1 As String, strTest2 As String, strTest3 As String)
Dim wbTestAddin As Workbook
Dim lastError As Long
AddIns("TestAddinCall").Installed = True
On Error Resume Next
Set wbTestAddin = Workbooks(AddIns("TestAddinCall").Name)
lastError = Err
On Error GoTo 0
If lastError <> 0 Then
Set wbTestAddin = Workbooks.Open(AddIns("TestAddinCall").FullName)
End If
Application.Run "TestAddinCall.xla!mytest", strTest1, strTest2, strTest3
AddIns("TestAddinCall").Installed = False
Dim strTestPrompt As String
strTestPrompt = "At least it got this far"
MsgBox strTestPrompt, vbInformation, "Test Message"
End Sub

Rampant Lion
11-06-2010, 04:46 PM
Thanks for the quick response, MD! It looks pretty straightforward...I'll test this out tomorrow...

Cheers,

Jay

Rampant Lion
11-07-2010, 02:29 PM
Works great, MD...Thank You!

Jay

:beerchug: