Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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
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
How can you open files with extension xlsx? Rajat[_2_] Excel Discussion (Misc queries) 4 March 4th 09 05:03 AM
How do I import a .STE extension (compressed XML) file to Excel? mayosm Excel Discussion (Misc queries) 2 September 9th 07 09:00 PM
files with no extension Jonathan Cooper Excel Discussion (Misc queries) 1 April 18th 06 08:49 PM
import snp file extension to MS Excel TSS Excel Discussion (Misc queries) 2 September 20th 05 11:28 PM
DELETING FILES FROM A FOLDER WITH SPECIFIC EXTENSION R v Deursen Excel Programming 1 May 28th 04 02:36 PM


All times are GMT +1. The time now is 04:30 AM.

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"