ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with multiple Auto_Open Macro's (https://www.excelbanter.com/excel-programming/320045-re-problem-multiple-auto_open-macros.html)

Peter T

Problem with multiple Auto_Open Macro's
 
Anyway, I tried your suggestion and it seems to work! However, I figured
out that I also have to make sure that the names of the Excel Files
don't contain a "-", because then the code you suggested doesn't work
(the AUTO_OPEN macro is not found).


Where workbook names include dash's, spaces and some other characters, for
many operations the name needs to be embraced with apostrophes. Working with
Tom's code, try changing the line:

Application.Run mybook.Name & "!Auto_Open"
to
Application.Run Chr(39) & mybook.Name & "'!Auto_Open"

It won't do any harm to include the apostrophes even if not required.

Regards,
Peter T

"BuZzzy FF" wrote in message
...
Hello Tom,

It seems our messages crossed somehow (I'm sorry, it's probably me being
completely new on this kind of discussion forums...)

Anyway, I tried your suggestion and it seems to work! However, I figured
out that I also have to make sure that the names of the Excel Files
don't contain a "-", because then the code you suggested doesn't work
(the AUTO_OPEN macro is not found).

Conclusion:
I have 2 solutions for the problem now:

1) Use the object method like Mr. Naik suggested and use the
RunAutoMacros xlAutoOpen statement like I did originally, but insert
also dummy calls since apparently only the 1st, 3th, 5th etc... call are
succesful (the others are just skipped)

2) Use the Object Method like Mr. Ogilvy suggested, but make sure that
the file names of the Excel files don't contain a "-".

Thanks for your help!

kind regards,

Filip Henderieckx

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




BuZzzy FF

Problem with multiple Auto_Open Macro's
 
Hello Peter,

Thanks for your help: This works.

Regards,

Filip

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Peter T

Problem with multiple Auto_Open Macro's
 
You're welcome, but it is of course Tom's suggestion and code that works for
you. My bit was trivial, to adapt to your particular needs. I imagine Tom
would have told you something similar on his return.

Regards,
Peter T

"BuZzzy FF" wrote in message
...
Hello Peter,

Thanks for your help: This works.

Regards,

Filip

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




David Kemp

Problem with multiple Auto_Open Macro's
 
Hi All,

Hope some of you are still around!
I tried using this as well but got an error.

-----------------------------------------------------CODE
Sub OpenWorkbooks()
Dim myBook As Workbook

Set myBook = Workbooks.Open(Filename:="C:\Documents and
Settings\kempdav1\My Documents\FBR\FBR Report v5 7075005.xls")
With myBook
Application.Run myBook.Name & "!Auto_Open"
.Close SaveChanges:=True
End With

Set myBook = Workbooks.Open(Filename:="C:\Documents and
Settings\kempdav1\My Documents\FBR\FBR Report v5 7051008.xls")
With myBook
Application.Run myBook.Name & "!Auto_Open"
.Close SaveChanges:=True
End With

Set myBook = Nothing
End Sub

--------------------------------------------------ENDCODE

I get the error:- run time error 1004
The macro 'FBR Report v5 7075005.xls!Auto_Open' cannot be found.

I am not big on coding or excel so its probably something obvious, any
ideas would be much appeciated.

Many thanks,

David

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 04:12 PM.

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