Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default how to dynamically import a text file

I don't want to hard code the path and file name. I want to make it dynamic.
This is what I have so far but it fails. Any ideas? Thanks a lot, Darren

Sub import_cmsies_in_trans()
Dim vInv_file As Variant
Dim vInv_file_A As Variant

vInv_file = Application.GetOpenFilename(Filefilter:= _
"Text Files(*.txt),*.txt", Title:="Open the CMSIES in transit file")

'I can see here that I have the path and name via the msgbox
vInv_file_A = "TEXT;" & vInv_file
MsgBox (vInv_file_A)

With ActiveSheet.QueryTables.Add(Connection:= _
"vinv_file_A", Destination:=Range("A1"))
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default how to dynamically import a text file

Try removing the quotes from around vinv_file_A in your QueryTables.Add
line

In article ,
Darren wrote:

I don't want to hard code the path and file name. I want to make it dynamic.
This is what I have so far but it fails. Any ideas? Thanks a lot, Darren

Sub import_cmsies_in_trans()
Dim vInv_file As Variant
Dim vInv_file_A As Variant

vInv_file = Application.GetOpenFilename(Filefilter:= _
"Text Files(*.txt),*.txt", Title:="Open the CMSIES in transit file")

'I can see here that I have the path and name via the msgbox
vInv_file_A = "TEXT;" & vInv_file
MsgBox (vInv_file_A)

With ActiveSheet.QueryTables.Add(Connection:= _
"vinv_file_A", Destination:=Range("A1"))

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
Can I import text file of cash flow to excel file then use formula Bumpa Excel Discussion (Misc queries) 2 May 28th 10 04:22 PM
Would Like to Automate Batch File Creation and Text FIle Import socrtwo Excel Discussion (Misc queries) 2 August 18th 06 03:54 PM
How do I import text file, analyze data, export results, open next file Geoffro Excel Programming 2 March 6th 05 08:02 PM
Import text file into excel with preset file layout, delimeters VBA meldrape Excel Programming 7 June 15th 04 08:31 PM
Get External Data, Import Text File, File name problem Scott Riddle Excel Programming 1 July 11th 03 05:40 PM


All times are GMT +1. The time now is 05:57 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"