Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tc tc is offline
external usenet poster
 
Posts: 40
Default Opening a file whose name is continuously changing

hi. i have a CSV file which i need to import on a regular basis. the
second half of the file name keeps changing eg. abcdXXXXXX where
xxxxxx is basically the date which keeps changing. can a macro be made
to automatically open this file and can this file name be split
inorder to use the date in the workbook for other purposes?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Opening a file whose name is continuously changing

On May 16, 12:03 pm, tc wrote:
hi. i have a CSV file which i need to import on a regular basis. the
second half of the file name keeps changing eg. abcdXXXXXX where
xxxxxx is basically the date which keeps changing. can a macro be made
to automatically open this file and can this file name be split
inorder to use the date in the workbook for other purposes?


Just use a wildcard filespec ...

MyFileName = Dir("C:\Somefolder\abcd??????.ext")
if MyFileName = "" Then
msgbox "No file found" exit sub
else
' Parse filespec ...
sDatePart = Split(MyFileName, "\")
sDatePart = Right(Split(sDatePart(Ubound(sDatePart), ".")(0), 6)
'Open file and use the data ...
end if

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
  #3   Report Post  
Posted to microsoft.public.excel.programming
tc tc is offline
external usenet poster
 
Posts: 40
Default Opening a file whose name is continuously changing

On May 17, 2:22 am, T Lavedas wrote:
On May 16, 12:03 pm, tc wrote:

hi. i have a CSV file which i need to import on a regular basis. the
second half of the file name keeps changing eg. abcdXXXXXX where
xxxxxx is basically the date which keeps changing. can a macro be made
to automatically open this file and can this file name be split
inorder to use the date in the workbook for other purposes?


Just use a wildcard filespec ...

MyFileName = Dir("C:\Somefolder\abcd??????.ext")
if MyFileName = "" Then
msgbox "No file found" exit sub
else
' Parse filespec ...
sDatePart = Split(MyFileName, "\")
sDatePart = Right(Split(sDatePart(Ubound(sDatePart), ".")(0), 6)
'Open file and use the data ...
end if

Tom Lavedas
===========http://members.cox.net/tglbatch/wsh/


Thanks Tom for your help
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
Changing Opening folder Blair Excel Worksheet Functions 2 July 1st 06 05:04 PM
Opening a file with changing dates kingkdz Excel Programming 3 June 27th 06 09:12 AM
Error opening a CSV from Web Browser after changing Region [email protected] Excel Discussion (Misc queries) 0 December 7th 05 08:09 PM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM
Opening Excel after changing settings and add-ins swesterm Excel Discussion (Misc queries) 3 December 29th 04 06:54 PM


All times are GMT +1. The time now is 07:21 PM.

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

About Us

"It's about Microsoft Excel"