P
pmartin1960
I am familiar with Excel VBA and now I wish to repeat some of my coding
of Excel from Access.
In Excel, I run the following code to test if a workbook is open:
Public Function WorkbookIsOpen(ByVal sWbkNameA As String) As Boolean
Dim wbkTemp As Workbook
On Error Resume Next
Set wbkTemp = Workbooks(sWbkNameA) ' Returns an error if not open
WorkbookIsOpen = (Err.Number = 0)
On Error GoTo 0
End Function
This code has always worked fine for me in Excel, but is failing when I
run it from Access. I have tried qualifying Workbook as
Excel.Workbook, and have added Excel to the Reference Library. When I
run the above code, if the relevant workbook is open, Err.Number should
be 0 but returns 9. Any suggestions appreciated.
Paul Martin
Melbourne, Australia
of Excel from Access.
In Excel, I run the following code to test if a workbook is open:
Public Function WorkbookIsOpen(ByVal sWbkNameA As String) As Boolean
Dim wbkTemp As Workbook
On Error Resume Next
Set wbkTemp = Workbooks(sWbkNameA) ' Returns an error if not open
WorkbookIsOpen = (Err.Number = 0)
On Error GoTo 0
End Function
This code has always worked fine for me in Excel, but is failing when I
run it from Access. I have tried qualifying Workbook as
Excel.Workbook, and have added Excel to the Reference Library. When I
run the above code, if the relevant workbook is open, Err.Number should
be 0 but returns 9. Any suggestions appreciated.
Paul Martin
Melbourne, Australia