Junior6202
Programmer
Hi all,
I'm fairly new to Vbs and I have a script that takes a particular csv file and converts it to excel. The problem is that the cvs file is automated and it always have a different name. I'm setting this script to run automatically so is there a way to set the .InitialFileName to pick every file .csv as opposed to a particular name. Thanks in advance.
Sub SaveAsXLSX()
Dim wbSource As Workbook
Dim vrtSelectedItem As Object
'Allows you to pick the CSV file from wherever it's been saved.
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "P:\test\QVD CoreCentric140306_000136011.csv"
.AllowMultiSelect = False
.Show
For Each vrtSelectedItem In .SelectedItems
wbSource = Workbooks.Open(vrtSelectedItem)
Next
End With
'Saves the file as an .xlsx file.
wbSource.SaveAs(Filename = "QVD_UPS.xlsx", FileFormat:=51)
End Sub
I'm fairly new to Vbs and I have a script that takes a particular csv file and converts it to excel. The problem is that the cvs file is automated and it always have a different name. I'm setting this script to run automatically so is there a way to set the .InitialFileName to pick every file .csv as opposed to a particular name. Thanks in advance.
Sub SaveAsXLSX()
Dim wbSource As Workbook
Dim vrtSelectedItem As Object
'Allows you to pick the CSV file from wherever it's been saved.
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "P:\test\QVD CoreCentric140306_000136011.csv"
.AllowMultiSelect = False
.Show
For Each vrtSelectedItem In .SelectedItems
wbSource = Workbooks.Open(vrtSelectedItem)
Next
End With
'Saves the file as an .xlsx file.
wbSource.SaveAs(Filename = "QVD_UPS.xlsx", FileFormat:=51)
End Sub