+ Reply to Thread
Results 1 to 2 of 2

Macro Attempt for Importing txt data

  1. #1
    Registered User
    Join Date
    06-13-2014
    Posts
    2

    Macro Attempt for Importing txt data

    Hello guys!

    I am Traian, a student trying to do his homework. I need your help!
    I have an .exe file that generates many .txt files. I am modifying the Preinput file and after I run the Application I get those many .txt files.
    I have tried to make a macro that imports in an Excel sheet the data I need from those files. So I have recorded the Macro as in the Archive I have attached (The Macro Enabled Excel document). I get an error if I run the Macro.

    I want to run this Macro after I change the Preinput commands in order to get some data for a graph.

    If you can explain me why I get the "Invalid call procedure or argument" I will manage to finish my homework.

    Thank you for your time!

    P.S.: I don't know why I cannot upload also the .txt files (which have 'File' Type)
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    06-13-2014
    Posts
    2

    Re: Macro Attempt for Importing txt data

    P.P.S.: This is the code:

    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;I:\Strutture per Veicoli Aerospaziali\Second Exercise\Exercise 2 - Macro Folder\IDA_prv_3." _
    , Destination:=Range("$C$1"))
    .CommandType = 0
    .Name = "IDA_prv_3."
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 850
    .TextFileStartRow = 1
    .TextFileParseType = xlFixedWidth
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1)
    .TextFileFixedColumnWidths = Array(24)
    .TextFileDecimalSeparator = "."
    .TextFileThousandsSeparator = " "
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    Range("F1").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;I:\Strutture per Veicoli Aerospaziali\Second Exercise\Exercise 2 - Macro Folder\IDA_extv_1." _
    , Destination:=Range("$F$1"))
    .CommandType = 0
    .Name = "IDA_extv_1."
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 850
    .TextFileStartRow = 1
    .TextFileParseType = xlFixedWidth
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1)
    .TextFileFixedColumnWidths = Array(24)
    .TextFileDecimalSeparator = "."
    .TextFileThousandsSeparator = " "
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    Range("I1").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;I:\Strutture per Veicoli Aerospaziali\Second Exercise\Exercise 2 - Macro Folder\IDA_extv_2." _
    , Destination:=Range("$I$1"))
    .CommandType = 0
    .Name = "IDA_extv_2."
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 850
    .TextFileStartRow = 1
    .TextFileParseType = xlFixedWidth
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1)
    .TextFileFixedColumnWidths = Array(24)
    .TextFileDecimalSeparator = "."
    .TextFileThousandsSeparator = " "
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    Range("L1").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;I:\Strutture per Veicoli Aerospaziali\Second Exercise\Exercise 2 - Macro Folder\IDD_extv_3." _
    , Destination:=Range("$L$1"))
    .CommandType = 0
    .Name = "IDD_extv_3."
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 850
    .TextFileStartRow = 1
    .TextFileParseType = xlFixedWidth
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1)
    .TextFileFixedColumnWidths = Array(24)
    .TextFileDecimalSeparator = "."
    .TextFileThousandsSeparator = " "
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    Range("O1").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;I:\Strutture per Veicoli Aerospaziali\Second Exercise\Exercise 2 - Macro Folder\IDA_extv_11." _
    , Destination:=Range("$O$1"))
    .CommandType = 0
    .Name = "IDA_extv_11."
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 850
    .TextFileStartRow = 1
    .TextFileParseType = xlFixedWidth
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1)
    .TextFileFixedColumnWidths = Array(24)
    .TextFileDecimalSeparator = "."
    .TextFileThousandsSeparator = " "
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.ScrollColumn = 2
    Range("R1").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;I:\Strutture per Veicoli Aerospaziali\Second Exercise\Exercise 2 - Macro Folder\IDB_extv_12." _
    , Destination:=Range("$R$1"))
    .CommandType = 0
    .Name = "IDB_extv_12."
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 850
    .TextFileStartRow = 1
    .TextFileParseType = xlFixedWidth
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1)
    .TextFileFixedColumnWidths = Array(25)
    .TextFileDecimalSeparator = "."
    .TextFileThousandsSeparator = " "
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.SmallScroll ToRight:=5
    Range("U1").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;I:\Strutture per Veicoli Aerospaziali\Second Exercise\Exercise 2 - Macro Folder\IDC_extv_13." _
    , Destination:=Range("$U$1"))
    .CommandType = 0
    .Name = "IDC_extv_13."
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 850
    .TextFileStartRow = 1
    .TextFileParseType = xlFixedWidth
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1)
    .TextFileFixedColumnWidths = Array(25)
    .TextFileDecimalSeparator = "."
    .TextFileThousandsSeparator = " "
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    ActiveWindow.SmallScroll Down:=5
    Range("C22").Select
    ActiveCell.FormulaR1C1 = "=R[-12]C[1]"
    Range("C23").Select
    ActiveCell.FormulaR1C1 = "=R[-4]C[4]"
    Range("C24").Select
    ActiveCell.FormulaR1C1 = "=R[-5]C[7]"
    Range("C25").Select
    ActiveCell.FormulaR1C1 = "=R[-6]C[10]"
    Range("C26").Select
    ActiveCell.FormulaR1C1 = "=R[-16]C[13]"
    Range("C27").Select
    ActiveCell.FormulaR1C1 = "=R[-17]C[16]"
    Range("C28").Select
    ActiveCell.FormulaR1C1 = "=R[-18]C[19]"
    Range("C29").Select
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Attempt to add array list to macro not working
    By capson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2014, 02:27 PM
  2. [SOLVED] Attempt to fetch data from another file using OFFSET() failed
    By billj in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-30-2013, 09:49 AM
  3. Excel Keeps crashing after macro attempt
    By phschris1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-28-2009, 10:24 PM
  4. Importing Data via Macro
    By acs013 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2009, 03:59 AM
  5. error in attempt to warn about macro security
    By Pierre via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2005, 06:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1