au-s Posted January 13, 2010 Posted January 13, 2010 Hi, I have this VBA macro which sort imports data from a text file. I do not know exactly how to make it good. I have two sheets, named On sheet I made a command button with this code: Private Sub CommandButton1_Click() ' ' Macro1 Macro ' Macro recorded 2/17/2008 by Hack ' ' With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;H:\MyPath\test.txt", _ Destination:=Range("A1")) .Name = "test.txt" .FieldNames = True .RowNumbers = True .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = True .RefreshStyle = xlOverwriteCells .SavePassword = False .SaveData = False .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = xlWindows .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = False .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = False .TextFileSpaceDelimiter = False .TextFileColumnDataTypes = Array(2) .Refresh BackgroundQuery:=False End With End Sub When I click it, it imports information from a textfile as you see. Allthough the information is printed out on sheet where the button is. I bet it has something to do with "With ActiveSheet" statement. I want the data from the textfile to be prionted in sheet . How? And my second question is how can this macro import data from all *.txt files under a certain path. In this case it's only one file. Is it like: "TEXT;H:\MyPath\*.txt", _ .Name = "*.txt" Thanx Quote
NBC Posted January 13, 2010 Posted January 13, 2010 Forgive me if I'm wrong but that looks morelike an Excel macro than an AutoCAD macro ? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.