VBA Check for Open Workbook in Excel. We have flexibility to open multiple workbooks at a time in MS office. While running macro we may want to check particular workbook is open or not. Let us see specified Workbook is open or not in the following tutorial.
Let us see the following macro to verify weather the Workbook is open or not using Dir Function in Excel VBA.
'VBA Verify for Open Workbook in Excel Sub Check_Open_Workbook() 'Variable declaration Dim oWorkbook As Workbook For Each oWorkbook In Workbooks If oWorkbook.Name = "Test_Workbook.xls" Then MsgBox "Specified Workbook is open.", vbInformation, "VBAF1 : Automation Made Easy" Else MsgBox "Specified Workbook is not open.", vbCritical, "VBAF1 : Automation Made Easy" End If Next End Sub
Note: lets assume ‘Test_Workbook.xls’ Workbook is not available. It shows the following output on the screen.
Output: Here is the output screenshot of above macro.
You can refer the following link for the step by step instructions.
Click on the following links of the useful resources. These helps to learn and gain more knowledge.