Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
how can I tell (with VB) if a file is already open?
Thanks, John |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
try something like the following: sub foo() dim wbk as workbook on error resume next set wbk = workbooks("your_workbookname.xls") if err.number<0 then msgbox "Workbook is not open" exit sub end if 'now your other code end sub -- Regards Frank Kabel Frankfurt, Germany John T. wrote: how can I tell (with VB) if a file is already open? Thanks, John |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
John,
Try something like Function IsWorkbookOpen(WBName As String) As Boolean On Error Resume Next Dim L As Long L = Len(Workbooks(WBName).Name) If L = 0 And StrComp(Right$(WBName, 4), ".xls") < 0 Then L = Len(Workbooks(WBName & ".xls").Name) End If IsWorkbookOpen = (L 0) End Function You can then call this function with code like If IsWorkbookOpen("Book1") = True Then -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "John T." wrote in message ... how can I tell (with VB) if a file is already open? Thanks, John |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The other interpretation of your question is if it is open, but not
necessarily in the instance of Excel containing the code. Then you could use: 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 -- Regards, Tom Ogilvy "John T." wrote in message ... how can I tell (with VB) if a file is already open? Thanks, John |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. | Excel Discussion (Misc queries) | |||
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. | Setting up and Configuration of Excel | |||
excel 2003 saved file will not open without a blank workbook open | Excel Discussion (Misc queries) | |||
In Excel - Use Windows Explorer instead of File Open to open file | Excel Discussion (Misc queries) | |||
How do I stop Excel from closing the open file each time I open a. | Setting up and Configuration of Excel |