Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50061

Checking if a workbook is open

$
0
0
I've found this Private Sub online and i'm just looking for help implementing it into my routine:

Code:

Private Function WorkbookIsOpen(wbname) As Boolean
'  Returns TRUE if the workbook is open
    Dim x As Workbook
    On Error Resume Next
    Set x = Workbooks(wbname)
    If Err = 0 Then WorkbookIsOpen = True _
        Else WorkbookIsOpen = False
End Function

I've put this in module3 of my book. The code I need it linking to is:
Code:

Sub UpdateTeam()


Dim wb As Workbook

   
   
    ChDir ThisWorkbook.Path
    ChDrive ThisWorkbook.Path
         
        x = Application.GetOpenFilename
           
            If x = False Then GoTo Cancel
   
        Set wb = Workbooks.Open(x)

But i dont know how to implement it. Any help appreciated.
John

Viewing all articles
Browse latest Browse all 50061

Trending Articles