ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is file opened? (https://www.excelbanter.com/excel-programming/290992-file-opened.html)

DonaldVdD

Is file opened?
 
How can I see if an Excel file is already opened

Because when it is I can't save a new one with the same name

Many thx in advanc

DonaldVdD

Bob Phillips[_6_]

Is file opened?
 


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"DonaldVdD" wrote in message
...
How can I see if an Excel file is already opened?

Because when it is I can't save a new one with the same name.

Many thx in advance

DonaldVdD




Bob Phillips[_6_]

Is file opened?
 
Donald,

Here is a simple function you can use

Function IsFileOpen(wb As String)
Dim oWb As Workbook

On Error Resume Next
Set oWb = Workbooks(wb)
On Error GoTo 0
IsFileOpen = Not oWb Is Nothing
End Function

Works like this

MsgBox IsFileOpen("Premiership 2003.xls")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"DonaldVdD" wrote in message
...
How can I see if an Excel file is already opened?

Because when it is I can't save a new one with the same name.

Many thx in advance

DonaldVdD




Tom Ogilvy

Is file opened?
 

http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open

Will check if it is open.

--
Regards,
Tom Ogilvy


"DonaldVdD" wrote in message
...
How can I see if an Excel file is already opened?

Because when it is I can't save a new one with the same name.

Many thx in advance

DonaldVdD





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com