open workbook in new window using VBA

  • Thread starter Thread starter ganesh25
  • Start date Start date
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.
 
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.
 
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.
 
Back
Top