ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   open workbook in new window using VBA (https://www.excelbanter.com/excel-programming/444313-open-workbook-new-window-using-vba.html)

ganesh25

open workbook in new window using VBA
 
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.

AB[_2_]

open workbook in new window using VBA
 
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.



On Mar 7, 1:31*pm, ganesh25 wrote:
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.



Walter Briscoe

open workbook in new window using VBA
 
In message
s.com of Mon, 7 Mar 2011 07:34:30 in microsoft.public.excel.programming
, AB writes
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.




On Mar 7, 1:31*pm, ganesh25 wrote:
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


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.
--
Walter Briscoe


All times are GMT +1. The time now is 05:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com