Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default My Macro keeps stopping??

Hi All

I have a macro in one workbook, which opens lots of other workbooks:-
Sub Auto_Open()
' Turn Off Auto Calcs....
With Application
.Calculation = xlManual
.CalculateBeforeSave = False
End With
' Open First workbook
Workbooks.Open(Filename:= _
"M&G.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen
'Open Second workbook.
Workbooks.Open(Filename:= _
"ET.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen

It does the first bit and opens the first workbook, the first workbook once open runs and Auto_Open macro does it's bit and then closes that Active window,
all is fine at this point the macro then comes back into this macro, where it should open the second workbook but it fails and the macro stops running


The Auto_Open macro in the workbooks that are opened looks like this:-
Sub Auto_Open()
do_i_run = Workbooks("Run All Service
Tracking.xls").Worksheets("Sheet1").Range("A15")
If (What_Date_Did_I_Run = What_Was_I_Opened) Then
If do_i_run = 10 Then
ActiveWorkbook.Close
End If
End If

This is to just get the workbooks to close for testing.


The reason I need this is that I have 12 workbooks that I need to open and runn Auto_Open macros, the macros collect data from one of our SQL servers, as I have 12 of these and I can only run one at a time I need them to run one after another, I can not use scheduler as I do not know if the data collection from the SQL box wll take 1 minute or 10 minutes, it just depends on how many users are connected to it when I try to run my work.


Can someone advise how to get my macro to continue to run

OR

How I could get one workbook to open once the previouse one has ran?

Many Thanks

Mark



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default My Macro keeps stopping??

I would close the workbook in the original code. when you close a workbook,
the code execution terminates - perhaps this termination is not returning
control to your original code.

--
Regards,
Tom Ogilvy


"Sh0t2bts" wrote in message
...
Hi All

I have a macro in one workbook, which opens lots of other workbooks:-
Sub Auto_Open()
' Turn Off Auto Calcs....
With Application
.Calculation = xlManual
.CalculateBeforeSave = False
End With
' Open First workbook
Workbooks.Open(Filename:= _
"M&G.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen
'Open Second workbook.
Workbooks.Open(Filename:= _
"ET.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen

It does the first bit and opens the first workbook, the first workbook once
open runs and Auto_Open macro does it's bit and then closes that Active
window,
all is fine at this point the macro then comes back into this macro, where
it should open the second workbook but it fails and the macro stops running


The Auto_Open macro in the workbooks that are opened looks like this:-
Sub Auto_Open()
do_i_run = Workbooks("Run All Service
Tracking.xls").Worksheets("Sheet1").Range("A15")
If (What_Date_Did_I_Run = What_Was_I_Opened) Then
If do_i_run = 10 Then
ActiveWorkbook.Close
End If
End If

This is to just get the workbooks to close for testing.


The reason I need this is that I have 12 workbooks that I need to open and
runn Auto_Open macros, the macros collect data from one of our SQL servers,
as I have 12 of these and I can only run one at a time I need them to run
one after another, I can not use scheduler as I do not know if the data
collection from the SQL box wll take 1 minute or 10 minutes, it just depends
on how many users are connected to it when I try to run my work.


Can someone advise how to get my macro to continue to run

OR

How I could get one workbook to open once the previouse one has ran?

Many Thanks

Mark


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default My Macro keeps stopping??

How would I do that??
I can close the active windows and close the application completly but I
don't know how to close another session of Excel?


Cheers

Mark




"Tom Ogilvy" wrote in message
...
I would close the workbook in the original code. when you close a

workbook,
the code execution terminates - perhaps this termination is not returning
control to your original code.

--
Regards,
Tom Ogilvy


"Sh0t2bts" wrote in message
...
Hi All

I have a macro in one workbook, which opens lots of other workbooks:-
Sub Auto_Open()
' Turn Off Auto Calcs....
With Application
.Calculation = xlManual
.CalculateBeforeSave = False
End With
' Open First workbook
Workbooks.Open(Filename:= _
"M&G.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen
'Open Second workbook.
Workbooks.Open(Filename:= _
"ET.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen

It does the first bit and opens the first workbook, the first workbook

once
open runs and Auto_Open macro does it's bit and then closes that Active
window,
all is fine at this point the macro then comes back into this macro, where
it should open the second workbook but it fails and the macro stops

running


The Auto_Open macro in the workbooks that are opened looks like this:-
Sub Auto_Open()
do_i_run = Workbooks("Run All Service
Tracking.xls").Worksheets("Sheet1").Range("A15")
If (What_Date_Did_I_Run = What_Was_I_Opened) Then
If do_i_run = 10 Then
ActiveWorkbook.Close
End If
End If

This is to just get the workbooks to close for testing.


The reason I need this is that I have 12 workbooks that I need to open and
runn Auto_Open macros, the macros collect data from one of our SQL

servers,
as I have 12 of these and I can only run one at a time I need them to run
one after another, I can not use scheduler as I do not know if the data
collection from the SQL box wll take 1 minute or 10 minutes, it just

depends
on how many users are connected to it when I try to run my work.


Can someone advise how to get my macro to continue to run

OR

How I could get one workbook to open once the previouse one has ran?

Many Thanks

Mark




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default My Macro keeps stopping??

What makes you think you are working in another session. The code as
written opens the workbooks in the same session of excel

Sub Auto_Open()
' Turn Off Auto Calcs....
With Application
.Calculation = xlManual
.CalculateBeforeSave = False
End With
' Open First workbook
With Workbooks.Open(Filename:= _
"M&G.xls", UpdateLinks:=0 _
)
.RunAutoMacros Which:=xlAutoOpen
.close SaveChanges:=False
End With
'Open Second workbook.
With Workbooks.Open(Filename:= _
"ET.xls", UpdateLinks:=0 _
)
.RunAutoMacros Which:=xlAutoOpen
.Close SaveChanges:=False
End With

--
Regards,
Tom Ogilvy


Sh0t2bts wrote in message
...
How would I do that??
I can close the active windows and close the application completly but I
don't know how to close another session of Excel?


Cheers

Mark




"Tom Ogilvy" wrote in message
...
I would close the workbook in the original code. when you close a

workbook,
the code execution terminates - perhaps this termination is not

returning
control to your original code.

--
Regards,
Tom Ogilvy


"Sh0t2bts" wrote in message
...
Hi All

I have a macro in one workbook, which opens lots of other workbooks:-
Sub Auto_Open()
' Turn Off Auto Calcs....
With Application
.Calculation = xlManual
.CalculateBeforeSave = False
End With
' Open First workbook
Workbooks.Open(Filename:= _
"M&G.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen
'Open Second workbook.
Workbooks.Open(Filename:= _
"ET.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen

It does the first bit and opens the first workbook, the first workbook

once
open runs and Auto_Open macro does it's bit and then closes that Active
window,
all is fine at this point the macro then comes back into this macro,

where
it should open the second workbook but it fails and the macro stops

running


The Auto_Open macro in the workbooks that are opened looks like this:-
Sub Auto_Open()
do_i_run = Workbooks("Run All Service
Tracking.xls").Worksheets("Sheet1").Range("A15")
If (What_Date_Did_I_Run = What_Was_I_Opened) Then
If do_i_run = 10 Then
ActiveWorkbook.Close
End If
End If

This is to just get the workbooks to close for testing.


The reason I need this is that I have 12 workbooks that I need to open

and
runn Auto_Open macros, the macros collect data from one of our SQL

servers,
as I have 12 of these and I can only run one at a time I need them to

run
one after another, I can not use scheduler as I do not know if the data
collection from the SQL box wll take 1 minute or 10 minutes, it just

depends
on how many users are connected to it when I try to run my work.


Can someone advise how to get my macro to continue to run

OR

How I could get one workbook to open once the previouse one has ran?

Many Thanks

Mark






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default My Macro keeps stopping??

Tom
I figured as two lots of Excel open at the bottom of the screen but it
doen't matter anyway what you suggested worked a treat and I can close the
windows using the first macro


Thanks

Mark




"Tom Ogilvy" wrote in message
...
What makes you think you are working in another session. The code as
written opens the workbooks in the same session of excel

Sub Auto_Open()
' Turn Off Auto Calcs....
With Application
.Calculation = xlManual
.CalculateBeforeSave = False
End With
' Open First workbook
With Workbooks.Open(Filename:= _
"M&G.xls", UpdateLinks:=0 _
)
.RunAutoMacros Which:=xlAutoOpen
.close SaveChanges:=False
End With
'Open Second workbook.
With Workbooks.Open(Filename:= _
"ET.xls", UpdateLinks:=0 _
)
.RunAutoMacros Which:=xlAutoOpen
.Close SaveChanges:=False
End With

--
Regards,
Tom Ogilvy


Sh0t2bts wrote in message
...
How would I do that??
I can close the active windows and close the application completly but I
don't know how to close another session of Excel?


Cheers

Mark




"Tom Ogilvy" wrote in message
...
I would close the workbook in the original code. when you close a

workbook,
the code execution terminates - perhaps this termination is not

returning
control to your original code.

--
Regards,
Tom Ogilvy


"Sh0t2bts" wrote in message
...
Hi All

I have a macro in one workbook, which opens lots of other workbooks:-
Sub Auto_Open()
' Turn Off Auto Calcs....
With Application
.Calculation = xlManual
.CalculateBeforeSave = False
End With
' Open First workbook
Workbooks.Open(Filename:= _
"M&G.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen
'Open Second workbook.
Workbooks.Open(Filename:= _
"ET.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen

It does the first bit and opens the first workbook, the first workbook

once
open runs and Auto_Open macro does it's bit and then closes that

Active
window,
all is fine at this point the macro then comes back into this macro,

where
it should open the second workbook but it fails and the macro stops

running


The Auto_Open macro in the workbooks that are opened looks like this:-
Sub Auto_Open()
do_i_run = Workbooks("Run All Service
Tracking.xls").Worksheets("Sheet1").Range("A15")
If (What_Date_Did_I_Run = What_Was_I_Opened) Then
If do_i_run = 10 Then
ActiveWorkbook.Close
End If
End If

This is to just get the workbooks to close for testing.


The reason I need this is that I have 12 workbooks that I need to open

and
runn Auto_Open macros, the macros collect data from one of our SQL

servers,
as I have 12 of these and I can only run one at a time I need them to

run
one after another, I can not use scheduler as I do not know if the

data
collection from the SQL box wll take 1 minute or 10 minutes, it just

depends
on how many users are connected to it when I try to run my work.


Can someone advise how to get my macro to continue to run

OR

How I could get one workbook to open once the previouse one has ran?

Many Thanks

Mark










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default My Macro keeps stopping??

That is controlled by Tools=Options=View, show windows in Task bar.

That option was added in xl2000.

--
Regards,
Tom Ogilvy

"Sh0t2bts" wrote in message
...
Tom
I figured as two lots of Excel open at the bottom of the screen but it
doen't matter anyway what you suggested worked a treat and I can close the
windows using the first macro


Thanks

Mark




"Tom Ogilvy" wrote in message
...
What makes you think you are working in another session. The code as
written opens the workbooks in the same session of excel

Sub Auto_Open()
' Turn Off Auto Calcs....
With Application
.Calculation = xlManual
.CalculateBeforeSave = False
End With
' Open First workbook
With Workbooks.Open(Filename:= _
"M&G.xls", UpdateLinks:=0 _
)
.RunAutoMacros Which:=xlAutoOpen
.close SaveChanges:=False
End With
'Open Second workbook.
With Workbooks.Open(Filename:= _
"ET.xls", UpdateLinks:=0 _
)
.RunAutoMacros Which:=xlAutoOpen
.Close SaveChanges:=False
End With

--
Regards,
Tom Ogilvy


Sh0t2bts wrote in message
...
How would I do that??
I can close the active windows and close the application completly but

I
don't know how to close another session of Excel?


Cheers

Mark




"Tom Ogilvy" wrote in message
...
I would close the workbook in the original code. when you close a
workbook,
the code execution terminates - perhaps this termination is not

returning
control to your original code.

--
Regards,
Tom Ogilvy


"Sh0t2bts" wrote in message
...
Hi All

I have a macro in one workbook, which opens lots of other

workbooks:-
Sub Auto_Open()
' Turn Off Auto Calcs....
With Application
.Calculation = xlManual
.CalculateBeforeSave = False
End With
' Open First workbook
Workbooks.Open(Filename:= _
"M&G.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen
'Open Second workbook.
Workbooks.Open(Filename:= _
"ET.xls", UpdateLinks:=0 _
).RunAutoMacros Which:=xlAutoOpen

It does the first bit and opens the first workbook, the first

workbook
once
open runs and Auto_Open macro does it's bit and then closes that

Active
window,
all is fine at this point the macro then comes back into this macro,

where
it should open the second workbook but it fails and the macro stops
running


The Auto_Open macro in the workbooks that are opened looks like

this:-
Sub Auto_Open()
do_i_run = Workbooks("Run All Service
Tracking.xls").Worksheets("Sheet1").Range("A15")
If (What_Date_Did_I_Run = What_Was_I_Opened) Then
If do_i_run = 10 Then
ActiveWorkbook.Close
End If
End If

This is to just get the workbooks to close for testing.


The reason I need this is that I have 12 workbooks that I need to

open
and
runn Auto_Open macros, the macros collect data from one of our SQL
servers,
as I have 12 of these and I can only run one at a time I need them

to
run
one after another, I can not use scheduler as I do not know if the

data
collection from the SQL box wll take 1 minute or 10 minutes, it just
depends
on how many users are connected to it when I try to run my work.


Can someone advise how to get my macro to continue to run

OR

How I could get one workbook to open once the previouse one has ran?

Many Thanks

Mark










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
stopping code Jase Excel Discussion (Misc queries) 1 October 6th 08 05:42 PM
Stopping a formula Roachy Excel Discussion (Misc queries) 3 July 1st 08 03:31 PM
Protect macro from stopping saman110 via OfficeKB.com Excel Discussion (Misc queries) 1 August 16th 07 08:22 PM
Stopping Excel macro pattern recgonition mal1920 New Users to Excel 2 November 17th 05 05:10 AM
Stopping a macro without using Ctrl Break Julian[_2_] Excel Programming 1 October 27th 03 02:39 AM


All times are GMT +1. The time now is 05:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"