Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
import only files with a certain extension
I need help trying to import only files with a given extension. I dont
need to consider the text string that comes before the extension. For example: I have a file named 1GC18950.057, but I only want to look at the .057 for this file in a known folder. How do I change the code below to only look for the extension and not the text string before it. Any help will be GREATLY appreciated!! With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Kevin\Desktop\data\1GC18950.057", |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
import only files with a certain extension
You have to provide a full file name in the connection string, so you need
some way to determine that before. One way : Dim Filename as string Const DirSearch as string="C:\Documents and Settings\Kevin\Desktop\data\" filename=dir(DirSearch & "*.057") if filename<"" then With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;" & DirSearch & filename,..etc Else msgbox "No .057 files" end if Or look into Application.GetOpenFilename for more flexibility. NickHK "kmcosta" wrote in message ups.com... I need help trying to import only files with a given extension. I dont need to consider the text string that comes before the extension. For example: I have a file named 1GC18950.057, but I only want to look at the .057 for this file in a known folder. How do I change the code below to only look for the extension and not the text string before it. Any help will be GREATLY appreciated!! With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;C:\Documents and Settings\Kevin\Desktop\data\1GC18950.057", |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can you open files with extension xlsx? | Excel Discussion (Misc queries) | |||
How do I import a .STE extension (compressed XML) file to Excel? | Excel Discussion (Misc queries) | |||
files with no extension | Excel Discussion (Misc queries) | |||
import snp file extension to MS Excel | Excel Discussion (Misc queries) | |||
DELETING FILES FROM A FOLDER WITH SPECIFIC EXTENSION | Excel Programming |