Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Closing Excel from Script

Since my high powered data analysis programming language doesn't seem to want
to play nice with Excel (where I want the data to go) I'm having to resort to
using a vbscript to act as a bridge between the two. In this script, after
the macro runs I want Excel to close down and not save. However, when it
closes it prompts me on whether I want to save or not. Is there a way to
have Excel not put up the prompt and close without saving? Thanks

Option Explicit
Dim objXL

Set objXL = WScript.CreateObject("Excel.Application")
objXL.WorkBooks.Open "\\Inmrc\irs\temp\Reports.xls"
objXL.Visible = TRUE ' Optional
objXL.Run("LoadData")
objXL.Quit
Set objXL = Nothing
  #2   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default Closing Excel from Script

Not sure if this would work in the "program" that you have, but Excel has two
things that it "checks" prior to closing.

If the SAVED property is set to TRUE then it will not ask to save the
document and also will not save the document
The other is the DisplayAlerts property. If it is set to FALSE then when
closing it will not question to save, and will not save.

So I *think* that
objXL.Saved = TRUE
or
objXL.DisplayAlerts = FALSE

would work, but I am not sure which will work.

DisplayAlerts is an application item where Saved relates directly to the
workbook. objXL looks like it may be an application object, so DisplayAlerts
may have to be the path you go with.

"kmbarz" wrote:

Since my high powered data analysis programming language doesn't seem to want
to play nice with Excel (where I want the data to go) I'm having to resort to
using a vbscript to act as a bridge between the two. In this script, after
the macro runs I want Excel to close down and not save. However, when it
closes it prompts me on whether I want to save or not. Is there a way to
have Excel not put up the prompt and close without saving? Thanks

Option Explicit
Dim objXL

Set objXL = WScript.CreateObject("Excel.Application")
objXL.WorkBooks.Open "\\Inmrc\irs\temp\Reports.xls"
objXL.Visible = TRUE ' Optional
objXL.Run("LoadData")
objXL.Quit
Set objXL = Nothing

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Closing Excel from Script

VBScript came back saying that objXL.Saved was not a supported property.
However, the objXL.DisplayAlerts = FALSE seemed to do the trick.
Thanks

"GB" wrote:

Not sure if this would work in the "program" that you have, but Excel has two
things that it "checks" prior to closing.

If the SAVED property is set to TRUE then it will not ask to save the
document and also will not save the document
The other is the DisplayAlerts property. If it is set to FALSE then when
closing it will not question to save, and will not save.

So I *think* that
objXL.Saved = TRUE
or
objXL.DisplayAlerts = FALSE

would work, but I am not sure which will work.

DisplayAlerts is an application item where Saved relates directly to the
workbook. objXL looks like it may be an application object, so DisplayAlerts
may have to be the path you go with.

"kmbarz" wrote:

Since my high powered data analysis programming language doesn't seem to want
to play nice with Excel (where I want the data to go) I'm having to resort to
using a vbscript to act as a bridge between the two. In this script, after
the macro runs I want Excel to close down and not save. However, when it
closes it prompts me on whether I want to save or not. Is there a way to
have Excel not put up the prompt and close without saving? Thanks

Option Explicit
Dim objXL

Set objXL = WScript.CreateObject("Excel.Application")
objXL.WorkBooks.Open "\\Inmrc\irs\temp\Reports.xls"
objXL.Visible = TRUE ' Optional
objXL.Run("LoadData")
objXL.Quit
Set objXL = Nothing

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
Closing workbooks w/o closing Excel Barb in MD Excel Discussion (Misc queries) 3 February 15th 10 06:42 PM
help with EXCEL SCRIPT Nastech Excel Discussion (Misc queries) 0 October 23rd 08 09:21 AM
Closing VB triggers closing Excel Minilek Excel Programming 2 August 6th 04 05:17 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM
closing excel after closing a workbook CWalsh[_2_] Excel Programming 3 January 21st 04 03:33 PM


All times are GMT +1. The time now is 12:18 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"