ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to import delimeter file (https://www.excelbanter.com/excel-programming/357983-macro-import-delimeter-file.html)

davemel

Macro to import delimeter file
 
I have created a macro to import a text file from our server (H: drive) but
whenever i run the macro it asks me to select the file from the Import Text
File window. I want to run the macro and for it to automatically load the
same text file into the spreadsheet every time without any user interaction.

The code created for my macro is shown below.

Range("A2").Select
With Selection.QueryTable
.Connection = "TEXT;H:\projects\quality database\qextract.txt"
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1)
.Refresh BackgroundQuery:=False

Any help greatly appreciated.

David


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com