Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Any way to grab a .csv file from a folder using Wildcards
Does anyone know of a way that I can grab a .csv file out of a local
folder with out specifying the exact document. I have created a macro that can take the CSV data and import into the Excel worksheet save it and print it but only if I code it to that exact CSV document. I was hoping to be able to just have it grab any CSV document in a particular folder. There will be only one CSV document at anytime in the folder but it will not always be named the same. Any ideas. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Any way to grab a .csv file from a folder using Wildcards
David,
You can use inFile = Application.GetOpenFilename which will open a standard "Open" file dialog box to browse for your .csv file and returns a file name and path ie (inFile = "C:\My Documents\MyCSV.csv") Dan E "David Johnston" wrote in message om... Does anyone know of a way that I can grab a .csv file out of a local folder with out specifying the exact document. I have created a macro that can take the CSV data and import into the Excel worksheet save it and print it but only if I code it to that exact CSV document. I was hoping to be able to just have it grab any CSV document in a particular folder. There will be only one CSV document at anytime in the folder but it will not always be named the same. Any ideas. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Any way to grab a .csv file from a folder using Wildcards
Here's another option,
This one has a fixed folder to look for the csv file in Private Sub CommandButton1_Click() On Error GoTo Endit Dim fs, f, f1, fc, s folderspec = "C:\My Documents" Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(folderspec) Set fc = f.Files i = 0 For Each f1 In fc If Right(f1.Name, 3) = "csv" Then inFileName = f1.ParentFolder.Path & "\" & f1.Name i = i + 1 End If Next ret = MsgBox(i & " CSV file(s) found ," & inFileName & " used", vbOKOnly) Endit: If i = 0 Then ret = MsgBox("No CSV file Found", vbOKOnly, "Bad Input") End If End Sub Dan E "David Johnston" wrote in message om... Does anyone know of a way that I can grab a .csv file out of a local folder with out specifying the exact document. I have created a macro that can take the CSV data and import into the Excel worksheet save it and print it but only if I code it to that exact CSV document. I was hoping to be able to just have it grab any CSV document in a particular folder. There will be only one CSV document at anytime in the folder but it will not always be named the same. Any ideas. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Any way to grab a .csv file from a folder using Wildcards
if there is only one csv file in the directory, try the following
f=dir("c:\my folder\*.csv") at this point f will be the filename including the path, Lynn S "David Johnston" wrote in message om... Does anyone know of a way that I can grab a .csv file out of a local folder with out specifying the exact document. I have created a macro that can take the CSV data and import into the Excel worksheet save it and print it but only if I code it to that exact CSV document. I was hoping to be able to just have it grab any CSV document in a particular folder. There will be only one CSV document at anytime in the folder but it will not always be named the same. Any ideas. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
opening file from ftp folder | Excel Discussion (Misc queries) | |||
in which folder can you save a .CSV file? | Excel Discussion (Misc queries) | |||
Create formula to grab file path | Excel Discussion (Misc queries) | |||
Need code to save file to new folder, erase from old folder | Excel Discussion (Misc queries) | |||
file folder macro's | Links and Linking in Excel |