ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error with Auto Open Macro (https://www.excelbanter.com/excel-programming/336053-error-auto-open-macro.html)

David

Error with Auto Open Macro
 
I have created a simple macro named Auto_Open and saved in in Personal.XLS. I
want the macro to start automatically and go to sheet 1, cell A1. Here is the
macro:

Sub Auto_Open()
Sheets(1).Activate
Range("A1").Activate
End Sub

But when I start excel trying to open a file, I get an error before the
worksheet even comes up. It is a run-time error 1004, Method 'Sheets' of
object '_Global' failed. What am I doing wrong?

Tom Ogilvy

Error with Auto Open Macro
 
Since Personal.xls is hidden, you should not try to select and activate in
that workbook.

--
Regards,
Tom Ogilvy

"David" wrote in message
...
I have created a simple macro named Auto_Open and saved in in

Personal.XLS. I
want the macro to start automatically and go to sheet 1, cell A1. Here is

the
macro:

Sub Auto_Open()
Sheets(1).Activate
Range("A1").Activate
End Sub

But when I start excel trying to open a file, I get an error before the
worksheet even comes up. It is a run-time error 1004, Method 'Sheets' of
object '_Global' failed. What am I doing wrong?




David

Error with Auto Open Macro
 
So how can I write a macro that will take me to sheet 1, cell A1 of any
workbook I open? Where should I save it?

"Tom Ogilvy" wrote:

Since Personal.xls is hidden, you should not try to select and activate in
that workbook.

--
Regards,
Tom Ogilvy

"David" wrote in message
...
I have created a simple macro named Auto_Open and saved in in

Personal.XLS. I
want the macro to start automatically and go to sheet 1, cell A1. Here is

the
macro:

Sub Auto_Open()
Sheets(1).Activate
Range("A1").Activate
End Sub

But when I start excel trying to open a file, I get an error before the
worksheet even comes up. It is a run-time error 1004, Method 'Sheets' of
object '_Global' failed. What am I doing wrong?





Tom Ogilvy

Error with Auto Open Macro
 
you would need to instantiate application level events and use the
application level workbook_Open event.

See Chip Pearson's page on application level events as a start:

http://www.cpearson.com/excel/appevent.htm

--
Regards,
Tom Ogilvy

"David" wrote in message
...
So how can I write a macro that will take me to sheet 1, cell A1 of any
workbook I open? Where should I save it?

"Tom Ogilvy" wrote:

Since Personal.xls is hidden, you should not try to select and activate

in
that workbook.

--
Regards,
Tom Ogilvy

"David" wrote in message
...
I have created a simple macro named Auto_Open and saved in in

Personal.XLS. I
want the macro to start automatically and go to sheet 1, cell A1. Here

is
the
macro:

Sub Auto_Open()
Sheets(1).Activate
Range("A1").Activate
End Sub

But when I start excel trying to open a file, I get an error before

the
worksheet even comes up. It is a run-time error 1004, Method 'Sheets'

of
object '_Global' failed. What am I doing wrong?







David

Error with Auto Open Macro
 
Well, it was just easier to create a menu button and attached the macro to
move to sheet 1, cell A1 if I needed to.
Thanks!

"Tom Ogilvy" wrote:

you would need to instantiate application level events and use the
application level workbook_Open event.

See Chip Pearson's page on application level events as a start:

http://www.cpearson.com/excel/appevent.htm

--
Regards,
Tom Ogilvy

"David" wrote in message
...
So how can I write a macro that will take me to sheet 1, cell A1 of any
workbook I open? Where should I save it?

"Tom Ogilvy" wrote:

Since Personal.xls is hidden, you should not try to select and activate

in
that workbook.

--
Regards,
Tom Ogilvy

"David" wrote in message
...
I have created a simple macro named Auto_Open and saved in in
Personal.XLS. I
want the macro to start automatically and go to sheet 1, cell A1. Here

is
the
macro:

Sub Auto_Open()
Sheets(1).Activate
Range("A1").Activate
End Sub

But when I start excel trying to open a file, I get an error before

the
worksheet even comes up. It is a run-time error 1004, Method 'Sheets'

of
object '_Global' failed. What am I doing wrong?








All times are GMT +1. The time now is 05:22 AM.

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