![]() |
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? |
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/ |
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 |
All times are GMT +1. The time now is 04:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com