Hello,
I need in the end of a macro to SaveAs the file in a defined path, but the name of the new .xls file to be defined by the code. I just want to check the name of the new file and click save button, not to do more than that.
Now the code is working corectly, but when the SaveAs Popup appears the name of the file is blank and I have to write it.
You have the code below:
This is strange because if I put in a single macro is working good, if I put this code combined with another macro it appear the problem mentioned above.
Thank you!
I need in the end of a macro to SaveAs the file in a defined path, but the name of the new .xls file to be defined by the code. I just want to check the name of the new file and click save button, not to do more than that.
Now the code is working corectly, but when the SaveAs Popup appears the name of the file is blank and I have to write it.
You have the code below:
Code:
Sub FileSaveAs() Dim file_name As Variant
Dim FName, Number, Data, Name As String
Number = "035"
Data = Format(Date, "dd/mm/yyyy")
Name = "Adrian"
FName = "ABT" & Mid(Number, 2) & " " & Data & " - " & Name
ChDir "C:\Users\Cipri Dia\Dropbox\"
' Get the file name.
file_name = Application.GetSaveAsFilename(FName, _
FileFilter:="Excel Files,*.xls,All Files,*.*", _
Title:="Save As File Name")
' See if the user canceled.
If file_name = False Then Exit Sub
' Save the file with the new name.
If LCase$(Right$(file_name, 4)) <> ".xls" Then
file_name = file_name & ".xls"
End If
ActiveWorkbook.SaveAs Filename:=file_name
End Sub
This is strange because if I put in a single macro is working good, if I put this code combined with another macro it appear the problem mentioned above.
Thank you!
Last edited: