open workbook in new window using VBA

G

ganesh25

Hi, I have macro which opens workbbok in new window but I am getting
the same window as activated. But I want original workbbok should be
activated.
Please help me?
Please find below code for the reference.
Sub test()
Dim MWBK As Workbook
Set MWBK = ActiveWorkbook
Dim exlApp As Excel.Application
Set exlApp = New Excel.Application
exlApp.Visible = True
exlApp.Workbooks.Open "D:\Documents and Settings\n404591\Desktop
\test.xls"
MWBK.Activate
End Sub

Thanks,
Ganesh K.
 
A

AB

Or, perhaps more importantly, - why do you need 2 intances of Excel
running? Can't you have the test.xls openned in the same instance of
Excel you're already running?
Then your code would work.
 
W

Walter Briscoe

In message <[email protected]
s.com> of Mon, 7 Mar 2011 07:34:30 in microsoft.public.excel.programming
Or, perhaps more importantly, - why do you need 2 intances of Excel
running? Can't you have the test.xls openned in the same instance of
Excel you're already running?
Then your code would work.

Because that is the way the OP wants it to work.
What version of Excel is the OP running? I run Excel 2003.

I changed the name passed to Open to name a file on my system.
I changed the window sizes with "Restore Down".
I had 2 windows open after running the code.

I have an application which uses the model the OP is trying to use.
An Excel file macro puts some data from the Internet on the screen.
It then grabs some user input and writes data to a second Excel file.
It then mail merges that second file with a Word file.

The only problem I found was that Excel crashed if the equivalent of
exlApp.Quit happened too soon after the second file was closed.
I solved that by deferring the quit until the mail merge was done.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top