I am attempting to import multiple excel workbook tabs to a single workbook. I was able to accomplish this when converting a text file and importing but I am now getting a Runtime Error 5 with the following code. The code in red is where it is having an issue. Any help would be greatly appreciated. I am new to VB and coding for that matter so a number of simple issues keep confounding me.
Sub ImportBPStoActiveworksheet()
'
' ImportBPStoActiveworksheet Macro
'
Dim myPath As String
myPath = Application.GetOpenFilename()
Dim myConn As String
myConn = myPath
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & myConn, _
Destination:=Range("$A$2"))
'
.CommandType = xlCmdTable
.CommandText = Array("RTTMEOD")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
End Sub
Sub ImportBPStoActiveworksheet()
'
' ImportBPStoActiveworksheet Macro
'
Dim myPath As String
myPath = Application.GetOpenFilename()
Dim myConn As String
myConn = myPath
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & myConn, _
Destination:=Range("$A$2"))
'
.CommandType = xlCmdTable
.CommandText = Array("RTTMEOD")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
End Sub