Hi guys
Long shot but hoping there might be an API genius out there somewhere or an imaginative vba-er with a workaround!
I'm writing an app in vba (Excel 2000) running purely off of userforms (i.e. no excel functionality whatsoever). Would have written it in VB but don't have access to this.
So. Here's the clever bit. I'm getting rid of the excel window by making it invisible. I'm using an API call (DrawMenuBar from user32.dll) to create my own button on the explorer taskbar, assigning my own icon, minimise, maximise etc so the app looks like an executable.
The problem: App runs fine disguised as it's own program until another .xls file is opened. Then it's obviously sharing a process (excel.exe) with another workbook. Even though i can hide the workbook window and trap the close process so it doesn't ask to save, when the user chooses to exit excel, my app is closing.
I've sorted if a workbook is already open when the app opens by creating another process with the following:
Private Sub Workbook_Open()
If Workbooks.Count > 1 Then
Dim xl As New Excel.Application
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open ActiveWorkbook.FullName, , True
Set xl = Nothing
ActiveWorkbook.Close False
Else:
Windows("myApp.xls").Visible = False
Application.Visible = False
frmTM.Show False
End If
End Sub
If this doesn't make sense please let me know - i've been racking my brains trying to find a way round this but so far can't come up with anything. Any workaround considered!
Thanks guys,
sugarflux
Long shot but hoping there might be an API genius out there somewhere or an imaginative vba-er with a workaround!
I'm writing an app in vba (Excel 2000) running purely off of userforms (i.e. no excel functionality whatsoever). Would have written it in VB but don't have access to this.
So. Here's the clever bit. I'm getting rid of the excel window by making it invisible. I'm using an API call (DrawMenuBar from user32.dll) to create my own button on the explorer taskbar, assigning my own icon, minimise, maximise etc so the app looks like an executable.
The problem: App runs fine disguised as it's own program until another .xls file is opened. Then it's obviously sharing a process (excel.exe) with another workbook. Even though i can hide the workbook window and trap the close process so it doesn't ask to save, when the user chooses to exit excel, my app is closing.
I've sorted if a workbook is already open when the app opens by creating another process with the following:
Private Sub Workbook_Open()
If Workbooks.Count > 1 Then
Dim xl As New Excel.Application
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open ActiveWorkbook.FullName, , True
Set xl = Nothing
ActiveWorkbook.Close False
Else:
Windows("myApp.xls").Visible = False
Application.Visible = False
frmTM.Show False
End If
End Sub
If this doesn't make sense please let me know - i've been racking my brains trying to find a way round this but so far can't come up with anything. Any workaround considered!
Thanks guys,
sugarflux