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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
If you're trying to save as an xlsx file, change xlNormal to xlOpenXMLWorkbook
 
Upvote 0

Forum statistics

Threads
1,215,345
Messages
6,124,408
Members
449,157
Latest member
mytux

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