I have an app (VB6) which instantiates Excell and creates/displays a workbook to the user via a button.
The problem I have is if the user closes Excell the app still works (i.e. the user can recreate a workbook using the button) but any subsequent workbooks created are not visible. The Excell.exe process is still active (viewed via task manager) and the application doesn't crash.
How can I get as newly created workbook to display?
Here's my code for opening/displaying a workbook...
[blue]
Public Function OpenWorkBook(strWorkBook As String) As Excel.Workbook
On Error GoTo err_OpenWorkBook
If XcellApp Is Nothing Then
Set XcellApp = New Excel.Application
Else
If XcellApp.Visible = False Then XcellApp.Visible = True
End If
'This closes any open workbook of this name..
On Error Resume Next
Workbooks(strWorkBook).Close SaveChanges:=False
On Error GoTo err_OpenWorkBook
Set OpenWorkBook = XcellApp.Workbooks.Open(App.Path + "\Templates\" + strWorkBook, , True)
XcellApp.Visible = True
Exit Function
err_OpenWorkBook:
MsgBox ("An error has occurred in S/R OpenWorkBokk " _
+ Chr(13) + "Error Number = " + CStr(Err.Number) _
+ Chr(13) + "Error Description = " + Err.Description)
End Function
[/blue]
Any help would be appreciated.....cheers
The problem I have is if the user closes Excell the app still works (i.e. the user can recreate a workbook using the button) but any subsequent workbooks created are not visible. The Excell.exe process is still active (viewed via task manager) and the application doesn't crash.
How can I get as newly created workbook to display?
Here's my code for opening/displaying a workbook...
[blue]
Public Function OpenWorkBook(strWorkBook As String) As Excel.Workbook
On Error GoTo err_OpenWorkBook
If XcellApp Is Nothing Then
Set XcellApp = New Excel.Application
Else
If XcellApp.Visible = False Then XcellApp.Visible = True
End If
'This closes any open workbook of this name..
On Error Resume Next
Workbooks(strWorkBook).Close SaveChanges:=False
On Error GoTo err_OpenWorkBook
Set OpenWorkBook = XcellApp.Workbooks.Open(App.Path + "\Templates\" + strWorkBook, , True)
XcellApp.Visible = True
Exit Function
err_OpenWorkBook:
MsgBox ("An error has occurred in S/R OpenWorkBokk " _
+ Chr(13) + "Error Number = " + CStr(Err.Number) _
+ Chr(13) + "Error Description = " + Err.Description)
End Function
[/blue]
Any help would be appreciated.....cheers