check all the workbook names that are open if it isn't it opens it.
check all the workbook names that are open if it isn't it opens it.
If I read this right you want to check if a specific workbook is open and if not to open it?
If so then use the following:
Dim wb As Workbook On Error Resume Next Set wb=application.workbooks("WorkbookName.xls") On Error Goto 0 'now reset error handling If wb Is Nothing Then application.workbooks.open("Path to file\WorkbookName.xls") end if
"Computers are useless. They can only give you answers." - Pablo Picasso
Mark Rowlinson FIA | The Code Net
Just another way to skin the cat
Sub FindWrkBk(PathToWorkbook As String, WrkBook As String) Dim IsThere As Boolean Dim Wrkbk As Workbook IsThere = False For Each Wrkbk In Workbooks If Wrkbk.Name = WrkBook Then IsThere = True End If Next If Not IsThere Then Application.Workbooks.Open PathToWorkbook & "\" & WrkBook End If End Sub Sub does() FindWrkBk "C:\WINDOWS\Desktop\stuff", "class.xls" End Sub
I just want to show this:
http://www.vbaexpress.com/forum/showthread.php?t=87
~Anne Troy
I was looking for that before but couldn't find it!
"Computers are useless. They can only give you answers." - Pablo Picasso
Mark Rowlinson FIA | The Code Net
My bad. I mass-moved some stuff to the wrong place.
~Anne Troy