From: XP on
I have an Excel File open and have performed some functions on it. Now I want
to get a reference to this file and close it without saving changes by
feeding the file name to a function, but this doesn't work; can someone
please correct it for me?

Function FileCloseXLSNoSave(argFileName)
Set oXL = GetObject("", "Excel.Application")
Set oWB = oXL.Workbooks.Close argFileName, False
Set oWB = Nothing
Set oXL = Nothing
End Function

Thanks much in advance.
From: Luuk on
XP schreef:
> I have an Excel File open and have performed some functions on it. Now I want
> to get a reference to this file and close it without saving changes by
> feeding the file name to a function, but this doesn't work; can someone
> please correct it for me?
>
> Function FileCloseXLSNoSave(argFileName)
> Set oXL = GetObject("", "Excel.Application")
> Set oWB = oXL.Workbooks.Close argFileName, False
> Set oWB = Nothing
> Set oXL = Nothing
> End Function
>
> Thanks much in advance.


Set oXL = GetObject("", "Excel.Application")
wscript.echo oXL.Workbooks.count
Set oXL = Nothing


returns "0" to me, even if i have a file open in Excel, so i think this
is the wrong way to solve your problem, but i'm not an expert in
vbscript ..... ;-)

--
Luuk
From: XP on

After much experimentation, I solved it using my method.

Thanks.

"XP" wrote:

> I have an Excel File open and have performed some functions on it. Now I want
> to get a reference to this file and close it without saving changes by
> feeding the file name to a function, but this doesn't work; can someone
> please correct it for me?
>
> Function FileCloseXLSNoSave(argFileName)
> Set oXL = GetObject("", "Excel.Application")
> Set oWB = oXL.Workbooks.Close argFileName, False
> Set oWB = Nothing
> Set oXL = Nothing
> End Function
>
> Thanks much in advance.