LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Open a New Instance of Excel

I am trying to open a new instance of Excel using VBA. Here is my
Workbook_Open():
Private Sub Workbook_Open()

'begin new instance
Dim blnIsOpen As Boolean
Dim blnReadOnly As Boolean
Dim blnOpenRef As Boolean
Dim wbRef As Workbook
Dim xlApp As Excel.Application
Dim wsWorking As Worksheet
Dim strPath As String
Dim sWorkbookToOpen As String
Dim sWorkbook As String

strPath = ThisWorkbook.Path & "/"
sWorkbook = "MainFile.xls"
sWorkbookToOpen = strPath & sWorkbook

blnIsOpen = True
On Error Resume Next
Set wbRef = Workbooks(sWorkbook)
On Error GoTo 0

If wbRef Is Nothing Then
Set xlApp = CreateObject("Excel.Application")
Set wbRef = xlApp.Workbooks.Open(sWorkbookToOpen, ,
blnReadOnly)
xlApp.Visible = True
blnIsOpen = False
End If
If blnOpenRef = True Then
wbRef.Activate
Else
' wsWorking.Activate
End If

'end new instance...

The code looks good, but it does NOT work. Right now, I’m popping
open a file named MainFile.xls and if there are no workbooks open,
when the code runs (inside of MainFile.xls), I can open a new instance
of Excel and do what I need to do in the new instance, and then use
Application.Quit for my MainFile.xls, and completely close it. If I
have an Excel file open (let’s call it File_A) and run my VBA,
MainFile.xls opens in the same instance of the File_A. I can’t use
Application.Quit to close MainFile.xls because that also closes
File_A.

Any ideas on how I can get the Workbook_Open() event to open an new
instance of Excel and then load my MainFile.xls into that new
instance?

Thanks so much!!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel instance stays open David Excel Programming 3 September 15th 08 02:00 AM
How to open a new instance of EXCEL and .xls file Launchnet Excel Worksheet Functions 10 June 19th 07 03:45 PM
open excel in a separate instance Eric Excel Discussion (Misc queries) 0 March 9th 07 08:01 PM
Open only one instance of Excel - 2003 poppy Excel Programming 6 May 12th 06 10:50 AM
How do i open a new instance Excel? Michael D. Reed Excel Programming 18 July 3rd 05 07:50 PM


All times are GMT +1. The time now is 06:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"