View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_2_] Dave Peterson[_2_] is offline
external usenet poster
 
Posts: 420
Default How to wait for addon to load

Did you try the code cleaner stuff?

On 06/24/2010 10:24, wrote:
Thanks for your replies. The entire thing was written in and is being used
in Excel 2003. It has the AddinInstall but when used, it will call
Auto_Add, at least in some situations. There is no explicit call to
Auto_Add in my code. (I didn't even know there was an Auto_Add until it
complained that it couldn't find it.)

On Tue, 22 Jun 2010 19:17:24 -0500, Dave Peterson
wrote:

I read the kb article that you mentioned and Auto_Add was replaced by the
workbook event AddInInstall. (I had never seen that old procedure. Sorry for
misleading you.)

This is just a guess or maybe just questions...

How old is your addin? What version of excel did you use to create it? Maybe
it was xl95 -- before the VBE when macros were stored in macro sheets????

Maybe there's something (whatever that means) lingering in all the junk that's
accumulated in that code.

Maybe cleaning the code with Rob Bovey's code cleaner would help:
You can find it he
http://www.appspro.com/
or directly
http://www.appspro.com/Utilities/CodeCleaner.htm

This essentially exports all the modules and rebuilds them. Depending on what
your addin does, you may be able to just drag and drop the
modules/userforms/code from the addin to a new workbook's project.

Then save that new workbook as an addin and experiment with that fresh version.

If that doesn't help, then I think I'd leave that dummy function in the addin
(with a nice comment explaining why it's there!).

ps. VBA's help for the AddinInstall event shows some sample code -- it adds a
control to the standard toolbar. (At least in xl2003's version of the VBA Help.)

pps. I'm not sure what the technical difference is between the workbook_open
event and the workbook_addininstall event. I've always used the workbook_open
event for the things I want to do. Actually, I still use the Auto_Open
procedure for lots of things.




On 06/22/2010 18:13, wrote:
The addin does not have an Auto_Add routine. (I wrote the addin).
However, when I added the line:
AddIns("RollForm").Installed = True
to Workbook_Activate(), Excel called RollForm.xla!Auto_Add and I received a
message that it couldn't find it. So I added:
sub Auto_Add()
end sub
to the addin and the message went away.

I put a Stop statement in Auto_Add and opened the Workbook and Excel 2003
did call Auto_Add. Some other things did not work and I assumed I was
supposed to include code in Sub Auto_Add to handle something or other, but
I had no idea what.

Via Google, I found that when you use AddIns("AddinName").Installed = True,
excel calls the addin's Auto_Add function but I found nothing describing
the function. (See:
http://databaseforum.info/16/9/cd250ee5bc1819d2.html
http://www.mrexcel.com/forum/showthread.php?t=35553
http://support.microsoft.com/kb/291294

http://msdn.microsoft.com/en-us/libr...ice.12%29.aspx

Several people mentioned that when they got the error they could
immediately step through the program with no errors. I also experienced
this which led me to think it might be a timing problem.

When I added the code you suggested to ThisWorkbook, Excel no longer seems
to call Auto_Add and everything works fine.

Prior to adding you code and when I had an Auto_Add routing which did
nothing, the error went away, the routine was called but there were all
sorts of other strange errors - example: The addin creates and writes a
text file, then closes it. In certain situations, it re-opens the file and
reads it. When Auto_Add was being called, it would fail in various ways
when it tried to re-open the file.

My addin is working fine now, but I would still like to understand why
Auto_Add is being called and what the developer is supposed to put in it.

Thanks for any insight.


On Tue, 22 Jun 2010 16:39:27 -0500, Dave Peterson
wrote:

Auto_Add is a procedure in that RollForm.xla addin.

I've never heard of that addin, so I don't have a guess what the procedure
actually does.

And it isn't one of the Auto run procedure names (Workbook_Open or Auto_Open)
that excel looks for when the workbook/addin is opened.

If the addin's project is unprotected, maybe you could look at the code?



On 06/22/2010 15:25, wrote:
Thanks for your reply. Your suggestion using OnTime works. Thank you.

I do have a question however. I found that, until I implemented your
solution, VB was calling "RollForm.xla!Auto_Add".

What is Auto_Add() for? What code should I put in it if I ever use it?
What does using your code keep it from calling AutoAdd()?

Thanks!!

On Tue, 22 Jun 2010 14:11:56 -0500, Dave Peterson
wrote:

Untested, but I'd try:

AddIns("RollForm").Installed = False
AddIns("RollForm").Installed = True

If that doesn't work, then maybe it is a timing issue.

You could use:

AddIns("RollForm").Installed = False
AddIns("RollForm").Installed = True
Application.OnTime Now + timeSerial(0,0,1), "Continue_Open"

End Sub

And the put the remainder of the code in that Continue_Open in a General module.


On 06/22/2010 13:57,
wrote:
In the ThisWorkbook module of a spreadsheet I have the statement:
AddIns("RollForm").Installed = True
The next line calls a sub in RollForm.xla.

The call fails because RollForm.xla is not yet loaded. If I step through
the code, it works fine.

How can I program a wait for RollForm.xla to be loaded?


Thanks!





--
Dave Peterson