![]() |
Activating workbook with variable Name
Hi,
I'm using VB to open each file in a certain directory, copy info from each into a file and then closing the opened file before looping to the next file. Everything works fine except that I cannot figure out the correct syntax to reactivate (or get the focus on) each file after copying from it. The variable name is MyFile defined as: MyFile = Dir("F:\common\budget\import\" & "*.xls") I've tried: Windows("myfile.xls").Activate Windows("myfile").Activate Myfile.Activate etc. without any luck. Help greatly appreciated |
Activating workbook with variable Name
I don't really understand what you are trying to do?
I have a example on my site that is doing something like you want http://www.rondebruin.nl/copy3.htm mybook in the code is the workbook that is open on the moment in the loop. -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Mark Klaus" wrote in message ... Hi, I'm using VB to open each file in a certain directory, copy info from each into a file and then closing the opened file before looping to the next file. Everything works fine except that I cannot figure out the correct syntax to reactivate (or get the focus on) each file after copying from it. The variable name is MyFile defined as: MyFile = Dir("F:\common\budget\import\" & "*.xls") I've tried: Windows("myfile.xls").Activate Windows("myfile").Activate Myfile.Activate etc. without any luck. Help greatly appreciated |
Activating workbook with variable Name
Workbooks(MyFile).Activate
No quotes. -- Regards, Tom Ogilvy Mark Klaus wrote in message ... Hi, I'm using VB to open each file in a certain directory, copy info from each into a file and then closing the opened file before looping to the next file. Everything works fine except that I cannot figure out the correct syntax to reactivate (or get the focus on) each file after copying from it. The variable name is MyFile defined as: MyFile = Dir("F:\common\budget\import\" & "*.xls") I've tried: Windows("myfile.xls").Activate Windows("myfile").Activate Myfile.Activate etc. without any luck. Help greatly appreciated |
All times are GMT +1. The time now is 02:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com