View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
GS[_5_] GS[_5_] is offline
external usenet poster
 
Posts: 226
Default How to wait for addon to load

presented the following explanation :
In the initial message in this thread I stated:
"In the ThisWorkbook module of a spreadsheet I have the statement:
AddIns("RollForm").Installed = True
The next line calls a sub in RollForm.xla."

Maybe that was poor terminology and thus not clear. However I meant that
it is in "Private Sub WorkBook_Open()" in ThisWorkbook. The WorkBook_Open()
does run. The .xla is loaded. The problem is that Excel did an implicit
(not coded by me) call Auto_Open() in the .xla which did not exist.

Any way adding the suggested code:
AddIns("RollForm").Installed = False
AddIns("RollForm").Installed = True
Application.OnTime Now + timeSerial(0,0,1), "Continue_Open"
dis solve the problem. It no longer calls Auto_Open() and everything iw
working great. I have no idea why it was calling Auto_Open, and given that
it did, I have no idea why it isn't now.


Excel will look for and call Auto_Open if there's no Workbook_Open proc
in ThisWorkbook. If you use Workbook.Open and have an Auto_Open proc
then you MUST tell Excel to Run that after opening. If you use
Workbook_Open then you don't have to do anything after opening.

When the addin is a member of the Addins collection, you also don't
need to do anything if you use its Installed prop to open it. In this
case Excel will look for Workbook_Open or Auto_Open on its own. That's
just normal behavior when dealing with XLAs because Excel expects an
XLA to have one or the other of these two procs as its startup routine.
It's not a requirement, though, that all XLAs require either one.

What I'm say is instead of calling the proc you call after opening the
addin, put that proc's code in either the Workbook_Open event proc or
an Auto_Open proc so you don't have to call it from wherever you're
calling it from. It appears that whatever this proc is, that you want
it to run immediately after the addin opens. So.., you can make this
proc one of the two startup procs mentioned OR call it from one of
those right within the addin.

--
Garry

Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc