Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Test to see if a workbook is open
Hello,
I would like to make a test before opening a file to see if there is a workbook (same name) already opened. if( workbook test.xls is open) then msgbox("You must close the file first") exit sub end if workbook.Open "C:\test.xls" Thanks, Alex -- Alex St-Pierre |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Test to see if a workbook is open
Alex
http://www.dicks-blog.com/archives/2...rkbook-exists/ -- Dick Kusleika Excel MVP Daily Dose of Excel www.dicks-blog.com Alex St-Pierre wrote: Hello, I would like to make a test before opening a file to see if there is a workbook (same name) already opened. if( workbook test.xls is open) then msgbox("You must close the file first") exit sub end if workbook.Open "C:\test.xls" Thanks, Alex |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Test to see if a workbook is open
Alex,
Try this: Function TestForOpenWorkBook(strFileName As String) As Boolean Dim objWorkBook As Workbook ErrorCleanUp: TestForOpenWorkBook = False For Each objWorkBook In Application.Workbooks If UCase(objWorkBook.Name) = strFileName Then TestForOpenWorkBook = True Exit Function End If '**** Workbook open Next '*** Loop thru workbooks Exit Function ErrorModule: msgbox err.desciption Resume ErrorCleanUp End Function Regards, Stewart "Alex St-Pierre" wrote: Hello, I would like to make a test before opening a file to see if there is a workbook (same name) already opened. if( workbook test.xls is open) then msgbox("You must close the file first") exit sub end if workbook.Open "C:\test.xls" Thanks, Alex -- Alex St-Pierre |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Test to see if a workbook is open
On Error Resume Next Set oWb = Workbooks("test.xls") On Error Goto 0 If Not oWb Is Nothing Then msgbox("You must close the file first") exit sub end if workbook.Open "C:\test.xls" -- HTH RP (remove nothere from the email address if mailing direct) "Alex St-Pierre" wrote in message ... Hello, I would like to make a test before opening a file to see if there is a workbook (same name) already opened. if( workbook test.xls is open) then msgbox("You must close the file first") exit sub end if workbook.Open "C:\test.xls" Thanks, Alex -- Alex St-Pierre |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Test to see if a workbook is open | Excel Discussion (Misc queries) | |||
Test for Open File | Excel Programming | |||
Test if a workbook is open already | Excel Programming | |||
Test that a workbook is open | Excel Programming | |||
test for workbook open | Excel Programming |