LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how tell if file already open?

Just for information, that depends on the windows settings. It will always
work with .xls, so suggest always to use .xls.

--
Regards,
Tom Ogilvy

"Kanan" wrote in message
...
your code will work without the .xls extension in the isopen call.
just fyi
kanan

"David" wrote:

?B?SWFuIEVsbGlvdHQ=?= wrote

Thanks for any help.
I have a macro that pastes some info into another workbook. I open the
workbook, then run the macro. I would like to make the macro code to
open the file if not already open. If I make the code open a file
without checking if it is already open, I would get a notice about
opening it twice. So I would like to code it so that it checks if the
file is already open. How do I tell if a file is already open? With
workbooks.something? Or windows.something? Thanks.


I'm currently using the following Function I found (wish I could credit

the
author):

Function IsOpen(ByRef BookName As String) As Boolean
On Error Resume Next
IsOpen = Not (Application.Workbooks(BookName) Is Nothing)
End Function

Called like this:

If IsOpen("yourfilename.xls") Then
'<your code here
Else
Workbooks.Open "yourfilename.xls"
End If

--
David





 
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
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Excel Discussion (Misc queries) 0 April 23rd 09 08:53 PM
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 2 July 8th 05 05:51 AM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 0 July 2nd 05 08:41 PM


All times are GMT +1. The time now is 10:41 PM.

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"