I have a code which i use to save my excel file to a specified folder.
I want to modify this code so that i can add " password" to the file.
Basically it will save the file and the user needs to enter the password to open the file .
the code which i use to save as is :
Private Sub CommandButton1_Click()
Dim path As String
Dim filename1 As String
Dim filename2 As String
path = "C:\Users\Dell\Desktop\Invoices\"
filename1 = Range("C3").Text
filename2 = Range("Q41").Text
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=path & filename1 & "-" & filename2 & ".xlsx", FileFormat:=xlOpenXMLWorkbook
Application.DisplayAlerts = True
End Sub
Bookmarks