Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proper methods for getting/managing Excel instances ? (vbscript)

Status
Not open for further replies.

blpcrs

Programmer
Aug 25, 2011
19
US
Hi All - This is in vbscript and not VBA, but figured the VBA MSFT community might have an answer/explanation of this.
What is the difference between these two methods of getting a currently running Excel process?

Set objExcel = GetObject( , "Excel.Application")
vs.
Set objExcel = eval("getobject(,""Excel.Application"")")

Which is the preferred method? Using the second line, I am curious if this leads to some inconsistencies in our scripts (ie .quit still has a 'do you want to save' popup despite calling objExcel.DisplayAlerts = false
Many thanks in advance!
 
I can't answer the main question since I'm not sure how Eval would respond (looks like it is running a line of code that you could generate programatically). But reading on I saw that when you're quitting Excel you're occasionally being asked to save when you don't want to be prompted. If you save your workbooks prior to closing or close the workbook and specifically tell Excel not to save any workbook changes then you'll be able to avoid having Excel ask that question.
 
Try to repeat .DisplayAlerts before .Quit.
MS changed the functionality of DisplayAlerts property in newer excel versions, it can be restored (set to True) automatically in some cases.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top