cheapdrunk
03-12-2006, 12:40 AM
Hi all,
I hope I'm not asking something really obvious here but....
I'm using the 'WorkbookOpen' event in VBA. This is saved in a class module in a workbook that is loaded during startup with Excel (v2003 Pro SP2) via the XLSTART directory. This macro runs fine. If I start Excel, the workbook loads, my macro recognises the WorkbookOpen event and I get a splash screen to say that it's running. What it then does is sits and waits until I open particular .XLS sheets and modifies them. This is all by design and is working as it should be.
BUT - If I attempt to start Excel by double-clicking on a .XLS sheet from within Explorer (for example), the first workbook is loaded (with my macro and the Workbookopen event), but NOT the .XLS sheet I just double clicked on! I then have to go back and re-double-click on it so that Excel will load it.
For clarification: Excel starts fine and will load a double clicked XLS sheet from within explorer if I disable the Workbookopen event.
If I start Excel from a normal shortcut, my macro loads, I get a splash screen and all is well. I can then load my selected workbook from [file][open], etc... with no problems and the macro works as it should.
I have tried making the VBA project an Addin. The only difference is that Excel then loads a new (blank) worksheet after loading Excel and my macro... but still will not open a double-clicked workbook.
It would appear that WorkbookOpen is not handing off control to Excel for any further workbooks that are opened at the same time as it is. Possibly not passing along environment variables that show Excel which workbook to load next? i.e. %1 %2 (for the DOS fans out there...)
Has anyone else had this same trouble with WorkbookOpen?
Thanks!
Dan http://www.mrexcel.com/board2/images/smiles/icon_smile.gif
I hope I'm not asking something really obvious here but....
I'm using the 'WorkbookOpen' event in VBA. This is saved in a class module in a workbook that is loaded during startup with Excel (v2003 Pro SP2) via the XLSTART directory. This macro runs fine. If I start Excel, the workbook loads, my macro recognises the WorkbookOpen event and I get a splash screen to say that it's running. What it then does is sits and waits until I open particular .XLS sheets and modifies them. This is all by design and is working as it should be.
BUT - If I attempt to start Excel by double-clicking on a .XLS sheet from within Explorer (for example), the first workbook is loaded (with my macro and the Workbookopen event), but NOT the .XLS sheet I just double clicked on! I then have to go back and re-double-click on it so that Excel will load it.
For clarification: Excel starts fine and will load a double clicked XLS sheet from within explorer if I disable the Workbookopen event.
If I start Excel from a normal shortcut, my macro loads, I get a splash screen and all is well. I can then load my selected workbook from [file][open], etc... with no problems and the macro works as it should.
I have tried making the VBA project an Addin. The only difference is that Excel then loads a new (blank) worksheet after loading Excel and my macro... but still will not open a double-clicked workbook.
It would appear that WorkbookOpen is not handing off control to Excel for any further workbooks that are opened at the same time as it is. Possibly not passing along environment variables that show Excel which workbook to load next? i.e. %1 %2 (for the DOS fans out there...)
Has anyone else had this same trouble with WorkbookOpen?
Thanks!
Dan http://www.mrexcel.com/board2/images/smiles/icon_smile.gif