Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Ensuring Excel start macros complete before terminating

I have a VBS script that runs each night. It is supposed to open an
Excel document so that it's start macros run and do some preprocessing.
It appears that I am terminating the application before the macros get
a chance to run. Is there a flag I can check to see if they are still
processing before I exit the application?

Thank you

Here is the code I am using. It is quite short, most of the code is for
troubleshooting purposes...

========================
On Error Resume Next

Set oExcel = CreateObject("Excel.application")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.OpenTextFile("autodialer_cube.log", 2, True)

oTS.WriteLine Now & " Opening workbook..."

oExcel.Workbooks.Open "\\CASK\groups\AutoDialer\AutoDialer.xls"
oExcel.ActiveWorkbook.RunAutoMacros 1
oExcel.ActiveWorkbook.Saved = True

oTS.WriteLine oExcel.ActiveWorkbook.Worksheets(1).Cells(5, 1).Value

If Err.Number < 0 Then
oTS.WriteLine Now & " (" & Err.Number & ") " & Err.Description
Err.Clear
End If

oTS.WriteLine Now & " Closing workbook..."

oExcel.Quit

If Err.Number < 0 Then
oTS.WriteLine Now & " (" & Err.Number & ") " & Err.Description
Err.Clear
End If
========================

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Ensuring Excel start macros complete before terminating

I don't see anything in your macro that wouldn't be synchronous, so I would
expect the process to finish for each step.

I guess it could depend on what is in the Auto_Open macro of the workbook.
If it is doing a background query, then this can be problematic, or using
Application.OnTime.

--
Regards,
Tom Ogilvy


"karlman" wrote in message
oups.com...
I have a VBS script that runs each night. It is supposed to open an
Excel document so that it's start macros run and do some preprocessing.
It appears that I am terminating the application before the macros get
a chance to run. Is there a flag I can check to see if they are still
processing before I exit the application?

Thank you

Here is the code I am using. It is quite short, most of the code is for
troubleshooting purposes...

========================
On Error Resume Next

Set oExcel = CreateObject("Excel.application")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.OpenTextFile("autodialer_cube.log", 2, True)

oTS.WriteLine Now & " Opening workbook..."

oExcel.Workbooks.Open "\\CASK\groups\AutoDialer\AutoDialer.xls"
oExcel.ActiveWorkbook.RunAutoMacros 1
oExcel.ActiveWorkbook.Saved = True

oTS.WriteLine oExcel.ActiveWorkbook.Worksheets(1).Cells(5, 1).Value

If Err.Number < 0 Then
oTS.WriteLine Now & " (" & Err.Number & ") " & Err.Description
Err.Clear
End If

oTS.WriteLine Now & " Closing workbook..."

oExcel.Quit

If Err.Number < 0 Then
oTS.WriteLine Now & " (" & Err.Number & ") " & Err.Description
Err.Clear
End If
========================



  #3   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Ensuring Excel start macros complete before terminating

Would it help to set a doc property to some value at the end of the
Auto_Open macro, and loop a read code in the calling code that will not
terminate until the value is set?

Ed

"Tom Ogilvy" wrote in message
...
I don't see anything in your macro that wouldn't be synchronous, so I

would
expect the process to finish for each step.

I guess it could depend on what is in the Auto_Open macro of the workbook.
If it is doing a background query, then this can be problematic, or using
Application.OnTime.

--
Regards,
Tom Ogilvy


"karlman" wrote in message
oups.com...
I have a VBS script that runs each night. It is supposed to open an
Excel document so that it's start macros run and do some preprocessing.
It appears that I am terminating the application before the macros get
a chance to run. Is there a flag I can check to see if they are still
processing before I exit the application?

Thank you

Here is the code I am using. It is quite short, most of the code is for
troubleshooting purposes...

========================
On Error Resume Next

Set oExcel = CreateObject("Excel.application")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.OpenTextFile("autodialer_cube.log", 2, True)

oTS.WriteLine Now & " Opening workbook..."

oExcel.Workbooks.Open "\\CASK\groups\AutoDialer\AutoDialer.xls"
oExcel.ActiveWorkbook.RunAutoMacros 1
oExcel.ActiveWorkbook.Saved = True

oTS.WriteLine oExcel.ActiveWorkbook.Worksheets(1).Cells(5, 1).Value

If Err.Number < 0 Then
oTS.WriteLine Now & " (" & Err.Number & ") " & Err.Description
Err.Clear
End If

oTS.WriteLine Now & " Closing workbook..."

oExcel.Quit

If Err.Number < 0 Then
oTS.WriteLine Now & " (" & Err.Number & ") " & Err.Description
Err.Clear
End If
========================





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Ensuring Excel start macros complete before terminating

Interesting idea! I will give it a try... Thanks

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
A complete novice guide to excell which course is best to start frank05 New Users to Excel 1 September 29th 06 02:42 AM
excel.exe is not terminating from task manager Inthi Excel Programming 0 November 28th 05 01:39 PM
Ensuring Macros are running ccarmock Excel Programming 2 October 1st 05 08:21 PM
How can I complete a spreadsheet using macros? Walter Heijboer Excel Discussion (Misc queries) 1 July 23rd 05 01:36 PM


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

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

About Us

"It's about Microsoft Excel"