Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Importing a csv file

Hi everybody,
I need to import a csv file and I work fine with this recorded macro:

Range("a1:j220").Select
Selection.ClearContents
Range("A1").Select

With ActiveSheet.QueryTables.Add(Connection:= _
"text;f:\maurizio\web\biliardo\script\eccel.cs v",
Destination:=Range("A4"))
.Name = "eccel"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 2)
.TextFileTrailingMinusNumbers = True
.refresh BackgroundQuery:=True
End With

My problem is how to avoid to specify the full path of the csv file as the
application
is to be used by other users and the path might not be the same.
Yes I know, everyone could match the path with its own machine
but I was wondering if a smarter way to do it exists.
Of course the csv file must be in the same application folder.
thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Importing a csv file

Possibly use the UNC as the file's address?

--
Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"



"Maurizio" wrote in message
...
Hi everybody,
I need to import a csv file and I work fine with this recorded macro:

Range("a1:j220").Select
Selection.ClearContents
Range("A1").Select

With ActiveSheet.QueryTables.Add(Connection:= _
"text;f:\maurizio\web\biliardo\script\eccel.cs v",
Destination:=Range("A4"))
.Name = "eccel"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 2)
.TextFileTrailingMinusNumbers = True
.refresh BackgroundQuery:=True
End With

My problem is how to avoid to specify the full path of the csv file as the
application
is to be used by other users and the path might not be the same.
Yes I know, everyone could match the path with its own machine
but I was wondering if a smarter way to do it exists.
Of course the csv file must be in the same application folder.
thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Importing a csv file

This will allow the user to select a file from a browser window.

Dim FName As Variant
FName = Application.GetOpenFilename(filefilter:="Text Files (*.csv),
*.csv", _
MultiSelect:=False)
With ActiveSheet.QueryTables.Add(Connection:= _
"text;"& FName, Destination:=Range("A4"))
etc, etc

Mike F
"Maurizio" wrote in message
...
Hi everybody,
I need to import a csv file and I work fine with this recorded macro:

Range("a1:j220").Select
Selection.ClearContents
Range("A1").Select

With ActiveSheet.QueryTables.Add(Connection:= _
"text;f:\maurizio\web\biliardo\script\eccel.cs v",
Destination:=Range("A4"))
.Name = "eccel"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 2)
.TextFileTrailingMinusNumbers = True
.refresh BackgroundQuery:=True
End With

My problem is how to avoid to specify the full path of the csv file as the
application
is to be used by other users and the path might not be the same.
Yes I know, everyone could match the path with its own machine
but I was wondering if a smarter way to do it exists.
Of course the csv file must be in the same application folder.
thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Importing a csv file

Great, this is the solution I was looking for.
Thank you
Maurizio Camporesi

"Mike Fogleman" wrote:

This will allow the user to select a file from a browser window.

Dim FName As Variant
FName = Application.GetOpenFilename(filefilter:="Text Files (*.csv),
*.csv", _
MultiSelect:=False)
With ActiveSheet.QueryTables.Add(Connection:= _
"text;"& FName, Destination:=Range("A4"))
etc, etc

Mike F
"Maurizio" wrote in message
...
Hi everybody,
I need to import a csv file and I work fine with this recorded macro:

Range("a1:j220").Select
Selection.ClearContents
Range("A1").Select

With ActiveSheet.QueryTables.Add(Connection:= _
"text;f:\maurizio\web\biliardo\script\eccel.cs v",
Destination:=Range("A4"))
.Name = "eccel"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 2)
.TextFileTrailingMinusNumbers = True
.refresh BackgroundQuery:=True
End With

My problem is how to avoid to specify the full path of the csv file as the
application
is to be used by other users and the path might not be the same.
Yes I know, everyone could match the path with its own machine
but I was wondering if a smarter way to do it exists.
Of course the csv file must be in the same application folder.
thanks




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
Importing TXT file from web Murtaza Excel Discussion (Misc queries) 0 September 26th 06 03:51 AM
Importing TXT file from web Murtaza Links and Linking in Excel 0 September 26th 06 03:51 AM
Importing a file(s) dan Excel Worksheet Functions 1 August 10th 06 04:08 AM
Importing text file, only option to edit existing file smokey99 Excel Discussion (Misc queries) 8 April 26th 06 09:08 PM
importing file cindy Excel Discussion (Misc queries) 1 January 17th 06 02:50 PM


All times are GMT +1. The time now is 02:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"