Triggering auto_open
On 27 juil, 01:00, GS wrote:
avi expressed precisely :
Hello,
With VBA I open a file which has am Auto_open macro but it looks that
it is not triggered as it would be if the file is opened directly (not
with VBA)
Is the a way to trigger it while opening through VBA?
Thanks
Avi
Avi,
When you open a workbook using Sub Auto_Open manually it behaves as
expected. When you open a workbook via automation you need to tell the
workbook (and Excel) to use Sub Auto_Open *as in the following example.
* Dim sPath As String
* sPath = ThisWorkbook.Path
* If Right$(sPath, 1) < "\" Then sPath = sPath & "\"
* Workbooks.Open sPath & g_sAPP_FILE
* Workbooks(g_sAPP_FILE).RunAutoMacros xlAutoOpen
--
Garry
Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Thanks to all of you
Looks that Garry's approach is the right one
Best regards
Avi
|