Controlling excel within VB .Net
Posted on 2006-04-30
VB .Net windows project. I'm opening an Excel Workbook from my project. To check if the workbook is allready open I use the following Function.
The function is not working as it should - it always return a: "Workbook not open" which means that more than one copy off the workbook is opened. What is wrong?
Public Function WorkbookOpen(ByVal WorkbookName As String) As Boolean
'Dim wb As xlapp.workbook
Dim wb As Microsoft.Office.Interop.Excel.Workbook
On Error Resume Next
wb = xlApp.Workbooks("WorkbookName")
On Error GoTo 0 'now reset error handling
If wb Is Nothing Then MsgBox("Workbook is not open")