Hi!
I am looking for a solution to define a name by saving as.
I think I'm almost there, but can't find the part where i can name it.
In steps:
1) Define the path and the name of the current file as string - to delete extension (=.csv)
2) Save current file as current name with .xls in folder where is current file saved before.
This is a part of my code - the part that is neccesary to see what I am doing:
'Naam van het bestand opnieuw definiëren, om extensie te wissen
Dim myOriginalFileNameToXls As String
Dim myFilePath As String
Dim myOriginalFileNameForSaving As String
Dim myFileName As String
myFilePath = ActiveWorkbook.FullName
myOriginalFileNameToXls = Replace(myFilePath, ".csv", ".xls")
myFileName = ActiveWorkbook.Name
myOriginalFileNameForSaving = Replace(myFileName, ".csv", "")
' Bestand opslaan als excelbestand met nieuwe naam
myOriginalFileNameForSaving = Application.GetSaveAsFilename(Title:="Bestand opslaan als:", _
FileFilter:="Microsoft Office excel-werkmap(*.xls),*.xls")
' Als er geen naam kan worden ingevuld, wordt het opslaan afgebroken
If myOriginalFileNameForSaving = False Then Exit Sub
' Er wordt normaal-gesproken automatisch de orginele bestandsnaam ingevuld
If LCase$(Right$(myOriginalFileNameForSaving, 4)) <> ".xls" Then myOriginalFileNameForSaving = myOriginalFileNameForSaving & ".xls"
' Als er geen naam aan wordt gegeven en toch op ok wordt gedruk wordt het de "oude" naam
ActiveWorkbook.SaveAs Filename:=myFilePath, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
The comment is in Dutch, but I think the code is readable...
Is there someone who can help me out?
Best regards,
Brigitte
Bookmarks