Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Open workbook "inactive"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Helmut - 24 Mar 2008 09:59 GMT
I open a workbook which has a different name each month - against this
workbook I run a PERSONAL.xls macro which requires that workbook
"Employees.xlsx" is open in the background.
How can I as first item in the Personal.xls-macro open this "Employees.xlsx"
workbook so it is "inactive" and the rest of the macro runs against the
firstly opened workbook which has a different name each month?
Jarek Kujawa - 24 Mar 2008 10:17 GMT
this month yr workbook is "March.xls"

let's presume you only open this a/m file

Edit the macro and put the following in the beginnig/as the first
command:

Workbboks(namethefullpath & "\" & "Employees.xlsx").Open
Workbooks("March.xls).Activate

then run the macro

Hope I didn't miss sth.

;-)
Helmut - 24 Mar 2008 10:52 GMT
Hi Jarek,
What you call "March.xls" is each month different, thus I cannot insert:
         Workbooks("March.xls).Activate
since I don't know the name of the file until I actually get it and open it.

To re-itereate:
     1. I manually open whatever the mothly file is called
     2. I then want to run a PERSONAL.xls "macro1" against that opened file
BUT
         FIRST I have to open "Employees.xlsx".
So the PERSONAL.xlsx "macro1" needs to have as its first line:
       Workbooks("Employees.xlsx").Open
BUT NOW I have to make this "inactive" and run the rest of the 'MACRO1'
against the other first opened workbook.

Understand??

> this month yr workbook is "March.xls"
>
[quoted text clipped - 11 lines]
>
> ;-)
Jarek Kujawa - 24 Mar 2008 11:01 GMT
presume your Personal.xls is hidden

then after     Workbooks("Employees.xlsx").Open

put this

ActiveWindow.ActivateNext

does this help?
Andy444 - 24 Mar 2008 12:45 GMT
Hi Helmut

One solution would be to open the monthly workbook as part of the macro as
follows and assign it to a variable as follows:

   Dim wkbThisMonthsWorkbook As Workbook
   Dim bOpened As Boolean
   
   bOpened = Application.FindFile
   If Not bOpened Then Exit Sub
   
   Set wkbThisMonthsWorkbook = Workbooks(Workbooks.Count)
   
   Call Workbooks.Open("Employees.xlsx")
   
   wkbThisMonthsWorkbook.Activate

HTH

> Hi Jarek,
> What you call "March.xls" is each month different, thus I cannot insert:
[quoted text clipped - 28 lines]
> >
> > ;-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.