Hello,
So I have two questions on the code below. can you help me modify this code to make the Q1 and Q2 work?
Q1. How to I prevent the code below from memorizing the "workbook connections" in menu data>connections. i need to import the data only without the data connection.
Q2. How to I take the imported file name (ex. Submission Review 02.09.16.xlsx) and give that name to my sheet1 (Submission Review 02.09.16) where the data was just imported? fyi, I open new excel file and then run the code below from dev>macros so the (sheet1) needs to show imported file name which would be "Submission Review 02.09.16." in this case.
thanks in advance for your help.
So I have two questions on the code below. can you help me modify this code to make the Q1 and Q2 work?
Q1. How to I prevent the code below from memorizing the "workbook connections" in menu data>connections. i need to import the data only without the data connection.
Q2. How to I take the imported file name (ex. Submission Review 02.09.16.xlsx) and give that name to my sheet1 (Submission Review 02.09.16) where the data was just imported? fyi, I open new excel file and then run the code below from dev>macros so the (sheet1) needs to show imported file name which would be "Submission Review 02.09.16." in this case.
thanks in advance for your help.
Code:
Sub Submission_Review()
'
' Submission Review Macro
'
'
Dim Filt As String
Dim FilterIndex As Integer
Dim Title As String
Dim FileName As Variant
Filt = "xls Files (*.xls),*.xls," & _
"All Files (*.*),*.*"
FilterIndex = 1
Title = "Select a Submission Report"
FileName = Application.GetOpenFilename _
(FileFilter:=Filt, _
FilterIndex:=FilterIndex, _
Title:=Title)
If FileName = False Then
MsgBox "No file was selected."
Exit Sub
End If
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & FileName, Destination:= _
Range("$A$1"))
'.CommandType = 0
.Name = "Submission Review"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub