Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Changing Opening folder | Excel Worksheet Functions | |||
Opening a file with changing dates | Excel Programming | |||
Error opening a CSV from Web Browser after changing Region | Excel Discussion (Misc queries) | |||
opening an excel file opens a duplicate file of the same file | Excel Discussion (Misc queries) | |||
Opening Excel after changing settings and add-ins | Excel Discussion (Misc queries) |