Hi I am fairly new to VBA but have used it before for simple Macros. Currently, I am trying to adapt a macro to import multiple XER files into separate sheets in a new Excel workbook. (An XER file is an Oracle Primavera backup file that reads in Notebook like a .TXT but will not open directly in Excel)
So far, I have managed to get the following code to work for a single import, but have not been able to adapt it to import multiple files. Each time I try to add multiple files in the getopenfilename dialogue I seem to get different errors.
Ideally, the macro would import each XER file into a separate worksheet and each worksheet would be named the imported filename. Any help would be appreciated.
Sub ImportXER()
'
Dim Ret
Ret = Application.GetOpenFilename("XER files (*.xer), *.xer")
If Ret <> False Then
Sheets.Add.Name = "New"
ActiveSheet.Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & Ret, Destination:=Range("$A$1"))
.Name = "resouces"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 936
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Range("A1").Select
End If
End Sub
Bookmarks