Hello Erock24,
I revised your macro to include the code needed to rename the file the user selects as a CSV file.
Sub ChangeFileToCSV()
Dim BS As Long, Dot As Long
Dim Oldfilename As String
Dim Oldfilepath As String
Dim Newfilename As String
TheFile = "\\datawhse\root\LAW81\LAWSON\print\EHARSKEY"
CreateObject("WScript.Shell").CurrentDirectory = TheFile
TheFile = Application.GetOpenFilename("Excel Files (*.*), *.*", , "Select the file and choose open.")
If TheFile = "False" Then Exit Sub
Oldfilename = TheFile
' Separate the file path and file name
BS = InStrRev(Oldfilename, "\")
Oldfilepath = Left(Oldfilename, BS)
Newfilename = Right(Oldfilename, Len(Oldfilename) - BS)
' Add the CSV extension to the file name
Dot = InStr(1, Newfilename, ".")
Newfilename = Oldfilepath & Left(Newfilename, Dot) & "csv"
' Rename the file
Name Oldfilename As Newfilename
Workbooks.Open Filename:=TheFile
End Sub
Sincerely,
Leith Ross
Bookmarks