Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Opening files from a variable (todays' date) folder name

Hi,

I got the code for opening all files within a particule folder yesterday
from William through NG.

When I wrote to William I had the requirement for opening all the Excel
files within the folder "c:\ccapps\ttlview\tmp\" but while fitting it with
other parts of the code I find that I need to open all the Excel files one
step down from "tmp" folder also. That step down folder will be determined
from today's date, formatted as "dd-mmm-yy".

I modified his code to the following one :-

Sub savingasnewname()
With Application.FileSearch
.NewSearch
p = Format(Now, "dd-mmm-yy")
.LookIn = ("c:\ccapps\ttlview\tmp\" & p)
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
.Execute
For i = 1 To .FoundFiles.Count
'MsgBox "Hi"
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))

Next i
End With

End sub

I thought that today being 10-Jun-04 I will get all the excel files within
folder "c:\ccapps\ttlview\tmp\10-Jun-04" bring opened, but the code wasnt
executing anything. I introduced a message box statement to know if the code
was going inside the "for loop" but it is not.

I understand that the problem is in ".Lookin" statement where Im combining a
constant and a variable. Is there any way I may resolve the same.

( The folder by today's date would always exist because this code is the
last in a sequence of codes and the previous codes have already created
folder with name being today's date.)

Regards,
Hari
India


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Opening files from a variable (todays' date) folder name

Untested, but try.......

..LookIn = "c:\ccapps\ttlview\tmp\" & Format(Now, "dd-mmm-yy")

--
XL2002
Regards

William



"Hari" wrote in message
...
| Hi,
|
| I got the code for opening all files within a particule folder yesterday
| from William through NG.
|
| When I wrote to William I had the requirement for opening all the Excel
| files within the folder "c:\ccapps\ttlview\tmp\" but while fitting it with
| other parts of the code I find that I need to open all the Excel files one
| step down from "tmp" folder also. That step down folder will be determined
| from today's date, formatted as "dd-mmm-yy".
|
| I modified his code to the following one :-
|
| Sub savingasnewname()
| With Application.FileSearch
| .NewSearch
| p = Format(Now, "dd-mmm-yy")
| .LookIn = ("c:\ccapps\ttlview\tmp\" & p)
| .SearchSubFolders = False
| .FileType = msoFileTypeExcelWorkbooks
| .Execute
| For i = 1 To .FoundFiles.Count
| 'MsgBox "Hi"
| Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
|
| Next i
| End With
|
| End sub
|
| I thought that today being 10-Jun-04 I will get all the excel files within
| folder "c:\ccapps\ttlview\tmp\10-Jun-04" bring opened, but the code wasnt
| executing anything. I introduced a message box statement to know if the
code
| was going inside the "for loop" but it is not.
|
| I understand that the problem is in ".Lookin" statement where Im combining
a
| constant and a variable. Is there any way I may resolve the same.
|
| ( The folder by today's date would always exist because this code is the
| last in a sequence of codes and the previous codes have already created
| folder with name being today's date.)
|
| Regards,
| Hari
| India
|
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Opening files from a variable (todays' date) folder name

HI William,

Thanx a lot.

I tried ur way in the morning and that time it didnt wok.

After ur postn I tried now and surprisingly it worked. ( Will keep u posted
if it doesnt work after some time)

Thanx again for solving my problems one after another.

Regards,
Hari
India


"William" wrote in message
...
Untested, but try.......

.LookIn = "c:\ccapps\ttlview\tmp\" & Format(Now, "dd-mmm-yy")

--
XL2002
Regards

William



"Hari" wrote in message
...
| Hi,
|
| I got the code for opening all files within a particule folder yesterday
| from William through NG.
|
| When I wrote to William I had the requirement for opening all the Excel
| files within the folder "c:\ccapps\ttlview\tmp\" but while fitting it

with
| other parts of the code I find that I need to open all the Excel files

one
| step down from "tmp" folder also. That step down folder will be

determined
| from today's date, formatted as "dd-mmm-yy".
|
| I modified his code to the following one :-
|
| Sub savingasnewname()
| With Application.FileSearch
| .NewSearch
| p = Format(Now, "dd-mmm-yy")
| .LookIn = ("c:\ccapps\ttlview\tmp\" & p)
| .SearchSubFolders = False
| .FileType = msoFileTypeExcelWorkbooks
| .Execute
| For i = 1 To .FoundFiles.Count
| 'MsgBox "Hi"
| Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
|
| Next i
| End With
|
| End sub
|
| I thought that today being 10-Jun-04 I will get all the excel files

within
| folder "c:\ccapps\ttlview\tmp\10-Jun-04" bring opened, but the code

wasnt
| executing anything. I introduced a message box statement to know if the
code
| was going inside the "for loop" but it is not.
|
| I understand that the problem is in ".Lookin" statement where Im

combining
a
| constant and a variable. Is there any way I may resolve the same.
|
| ( The folder by today's date would always exist because this code is the
| last in a sequence of codes and the previous codes have already created
| folder with name being today's date.)
|
| Regards,
| Hari
| India
|
|




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding files in a folder. Variable not defined error. Ayo Excel Discussion (Misc queries) 1 March 14th 08 01:14 PM
Default folder for opening/saving files Dino Excel Discussion (Misc queries) 2 July 5th 07 11:28 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
Activating "Todays Date" column upon opening? Jeremy H via OfficeKB.com Excel Discussion (Misc queries) 3 August 25th 05 02:36 AM
Opening all txt files in a folder and saving as excel Jason Excel Programming 1 February 23rd 04 09:01 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"