ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problems creating a dll in Excel 2003 using addin designer (https://www.excelbanter.com/excel-programming/314341-problems-creating-dll-excel-2003-using-addin-designer.html)

Tammy[_5_]

Problems creating a dll in Excel 2003 using addin designer
 
I have an Excel addin which I need to distribute so have created a com
addin using the addin designer. After much searching in Groups I have
it at the stage where it creates the buttons it needs to when Excel is
opened. I've copied the forms, modules and class modules from my xla
file into the addin but am having trouble getting the code to work
when it's called by the relevant button. (ie I have code that will
only run if a workbook is open. When I run it in Excel with a
workbook open it returns 0 as the workbook count.)

I think it's because when the code runs it's creating a new instance
of excel.exe and referring to that rather than the current instance.
When I check in task manager when I first open Excel there's one
Excel.exe yet when I run this macro there's two.

I copied some of the code into VB6 so I could debug it and found that
if I added the getobject line (ie Set objXL = GetObject (,
"Excel.Application") it worked. Trouble is when I copy that code into
the addin project in Excel I get the "ActiveX Component cannot create
object" message. The project references Excel so I don't know why I'm
getting that message. Any suggestions would be really appreciated!!

The other problem I have which may be caused by the same thing is that
when I calls the dialogs(wddialogsfileopen).show line, it doesn't
appear until I've closed Excel! Again - any suggestions greatly
appreciated.

Tammy

Tammy[_5_]

Problems creating a dll in Excel 2003 using addin designer
 
I've had some success since I posted this question and have actually
sorted out those problems (again thanks to more searching in Google
groups!). I needed to set the objXL variable as the application in
the onconnection procedure.

Have another problem now though. I need to use some of the functions
I've created in the dll in another excel template. I've set the
reference and have added the following code into the template.

Dim cAlemy As cAddin.cProcedures ''' Declare the variable
Set cAlemy = cAddin.GetProcedures()

The addin has code in the standard modules to instantiate the new
class

Public Function GetProcedures() As cProcedures
Set GetProcedures = New cProcedures
End Function

The class I'm trying to access is set to publicnotcreatable in the
instancing property.

The problem is the code debugs at .GetProcedures() in the
Set cAlemy = cAddin.GetProcedures() line saying that it can't find
method or member. I know it's probably something small I'm
overlooking but I'm new to this so any help would be great!

Cheers,
Tammy



(Tammy) wrote in message . com...
I have an Excel addin which I need to distribute so have created a com
addin using the addin designer. After much searching in Groups I have
it at the stage where it creates the buttons it needs to when Excel is
opened. I've copied the forms, modules and class modules from my xla
file into the addin but am having trouble getting the code to work
when it's called by the relevant button. (ie I have code that will
only run if a workbook is open. When I run it in Excel with a
workbook open it returns 0 as the workbook count.)

I think it's because when the code runs it's creating a new instance
of excel.exe and referring to that rather than the current instance.
When I check in task manager when I first open Excel there's one
Excel.exe yet when I run this macro there's two.

I copied some of the code into VB6 so I could debug it and found that
if I added the getobject line (ie Set objXL = GetObject (,
"Excel.Application") it worked. Trouble is when I copy that code into
the addin project in Excel I get the "ActiveX Component cannot create
object" message. The project references Excel so I don't know why I'm
getting that message. Any suggestions would be really appreciated!!

The other problem I have which may be caused by the same thing is that
when I calls the dialogs(wddialogsfileopen).show line, it doesn't
appear until I've closed Excel! Again - any suggestions greatly
appreciated.

Tammy



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

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