ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open but not activate (https://www.excelbanter.com/excel-programming/376353-open-but-not-activate.html)

Craig McK

Open but not activate
 
Hi

Is it possible to open a workbook, but not activate it

My problem is that I need to open a workbook to get data from (MASTER), but
I then need to open (SLAVE) again to get the criteria from, but (SLAVE) has
not been saved at this point. I tried to save the (SLAVE), but with no luck
as follows


' fname is the (SLAVE) workbook

fname = Application.GetSaveAsFilename
ActiveWorkbook.SaveAs Filename:=fname
Workbooks.Open "MASTER"
Workbooks(fname).Activate

Thanks

Bob Phillips

Open but not activate
 
I think the problem is that you are trying to activate by path and name, not
just name

Try

' fname is the (SLAVE) workbook

fname = Application.GetSaveAsFilename
ActiveWorkbook.SaveAs Filename:=fname
fShortName = ACtiveworkbook.Name
Workbooks.Open "MASTER"
Workbooks(fShortName).Activate


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Craig McK" wrote in message
...
Hi

Is it possible to open a workbook, but not activate it

My problem is that I need to open a workbook to get data from (MASTER),

but
I then need to open (SLAVE) again to get the criteria from, but (SLAVE)

has
not been saved at this point. I tried to save the (SLAVE), but with no

luck
as follows


' fname is the (SLAVE) workbook

fname = Application.GetSaveAsFilename
ActiveWorkbook.SaveAs Filename:=fname
Workbooks.Open "MASTER"
Workbooks(fname).Activate

Thanks




Craig McK

Open but not activate
 
Thanks bob
Would have been there for a while trying to work that one out

Craig

"Bob Phillips" wrote:

I think the problem is that you are trying to activate by path and name, not
just name

Try

' fname is the (SLAVE) workbook

fname = Application.GetSaveAsFilename
ActiveWorkbook.SaveAs Filename:=fname
fShortName = ACtiveworkbook.Name
Workbooks.Open "MASTER"
Workbooks(fShortName).Activate


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Craig McK" wrote in message
...
Hi

Is it possible to open a workbook, but not activate it

My problem is that I need to open a workbook to get data from (MASTER),

but
I then need to open (SLAVE) again to get the criteria from, but (SLAVE)

has
not been saved at this point. I tried to save the (SLAVE), but with no

luck
as follows


' fname is the (SLAVE) workbook

fname = Application.GetSaveAsFilename
ActiveWorkbook.SaveAs Filename:=fname
Workbooks.Open "MASTER"
Workbooks(fname).Activate

Thanks






All times are GMT +1. The time now is 11:22 AM.

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