Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
XL file opened using automation - how close?
I have a program that is run by Scheduled Task. This program opened an XL
file using automation as designed, however, now the file is hanging open and I can only get to it "read only". How can I regain control over this file and close it? Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
XL file opened using automation - how close?
If you have a scripting tool use the below code. OR .Paste the below code to
a notepad and save as <somefilename.vbs. From explorer double click the file to execute/ Dim appExcel Set appExcel = GetObject(, "Excel.Application") If Not appExcel is Nothing Then appExcel.DisplayAlerts = False appExcel.Quit End If -- Jacob (MVP - Excel) "xp" wrote: Hi Jacob, Thanks; however, I should have been more clear in my original post, how can I do this programmatically? Is it possible to get a reference to the running instance from a separate file (say VBScript or XL) and close the file? If so how? Thanks again! "Jacob Skaria" wrote: Did you try after closing Excel Application. If it is hidden instance from 'Task Manager'close all 'Excel applications' and then try -- Jacob (MVP - Excel) "xp" wrote: I have a program that is run by Scheduled Task. This program opened an XL file using automation as designed, however, now the file is hanging open and I can only get to it "read only". How can I regain control over this file and close it? Thanks! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
XL file opened using automation - how close?
Sure, you can..
Dim appExcel,WB On Error Resume Next Set appExcel = GetObject(, "Excel.Application") On Error Goto 0 If Not appExcel is Nothing Then Set WB = appExcel.Workbooks("MyBook.xlsm") WB.Close False End If Set WB = Nothing Set appExcel = Nothing -- Jacob (MVP - Excel) "xp" wrote: Thanks so much Jacob! That works! May I just ask one last thing? Say my file name is "MyBook.xlsm" - is there a way to get a reference just to that file and close only that file? "Jacob Skaria" wrote: Missed error handling... Dim appExcel On Error Resume Next Set appExcel = GetObject(, "Excel.Application") On Error Goto 0 If Not appExcel is Nothing Then appExcel.DisplayAlerts = False appExcel.Quit End If -- Jacob (MVP - Excel) "Jacob Skaria" wrote: If you have a scripting tool use the below code. OR .Paste the below code to a notepad and save as <somefilename.vbs. From explorer double click the file to execute/ Dim appExcel Set appExcel = GetObject(, "Excel.Application") If Not appExcel is Nothing Then appExcel.DisplayAlerts = False appExcel.Quit End If -- Jacob (MVP - Excel) "xp" wrote: Hi Jacob, Thanks; however, I should have been more clear in my original post, how can I do this programmatically? Is it possible to get a reference to the running instance from a separate file (say VBScript or XL) and close the file? If so how? Thanks again! "Jacob Skaria" wrote: Did you try after closing Excel Application. If it is hidden instance from 'Task Manager'close all 'Excel applications' and then try -- Jacob (MVP - Excel) "xp" wrote: I have a program that is run by Scheduled Task. This program opened an XL file using automation as designed, however, now the file is hanging open and I can only get to it "read only". How can I regain control over this file and close it? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
XL file opened using automation - how close? | Excel Programming | |||
XL file opened using automation - how close? | Excel Programming | |||
XL file opened using automation - how close? | Excel Programming | |||
Book1 default - does not close once another file is opened | New Users to Excel | |||
Close file and run macro from newly opened file | Excel Programming |