Save as with Writerespassword

jaik22

Board Regular
Joined
Sep 23, 2016
Messages
102
HTML:
Sub PasswordSave()Application.DisplayAlerts = FalseApplication.ScreenUpdating = False
SaveAsName = Application.GetSaveAsFilename( _FileFilter:="Excel Files (*.xlsx), *.xlsx")
ActiveWorkbook.SaveAs Filename:=SaveAsName, FileFormat:= _xlNormal, WriteResPassword:="test", ReadOnlyRecommended:=False _, CreateBackup:=False
End Sub

Hello, I have code above to let users choose save as path and save. However, after saving, I get an error when I open up the saved file

error message:
"The file format or file extension is no valid. Verify that the file has not been corrupted and that the file extension matches the format of the file".

However If i don't use vba and save file as xlsx extension, file works without any problem.(original file has xls extension.)

Also is there any way to set up, to display current location of the workbook when saving interface pops up?

Does anyone has good idea on this? Anything helps!

Thank you!
 
Last edited:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If you're trying to save as an xlsx file, change xlNormal to xlOpenXMLWorkbook
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top