Saving a password protected workbook without a password

baldwynward

New Member
Joined
Oct 16, 2014
Messages
10
I have a workbook with a macro to save the file with a new name. However I can't seem to save it as a .xlsx - when I go to open it I get a message saying it doesn't recognise the format. And also it opens up as password protected.

My code is:
Sub FolderPicker_SaveAs()

'Aug 29, 2014

'file name in cell e6

Sheets("Client Data").Select
Range("d5").Copy
Range("e5").PasteSpecial Paste:=xlPasteValues


Dim fPath
Dim fName
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = True Then
fPath = .SelectedItems(1) & "\"
fName = fPath & Range("e5").Value & ".xlsm"
Call MsgBox(fName, vbInformation, "Save Path")
ThisWorkbook.SaveAs Filename:=fName

Range("e5").Select
Selection.ClearContents

Range("b5").Select

Worksheets("Client Data").Visible = False

Sheets("Questionnaire").Select

End If
End With
End Sub

I'm guessing I'm missing something to do with WriteResPassword but can't see how to put this in the code. I'm also guessing I need to replace .xlsx with FileFormat:=51 but can't work out how to put this in either.

Can anyone help?

Thanks
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try using something like this:

Code:
ThisWorkbook.SaveAs _
Filename:=fName, _
Password:="" _
FileFormat:=xlOpenXMLWorkbookMacroEnabled

Is that something you can work with?
 
Upvote 0
Hi Ron

I've tried adding

Code:
fName = fPath & Range("e5").Value & ".xlsm"
Password:="" 
Call MsgBox(fName, vbInformation, "Save Path")

But i get a Compile error?

Re the file format, i actually want to save it as a non-macro enabled - so just an .xlsx. If I change the .xlsm in my code to .xlsx then it won't open properly?
 
Upvote 0

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

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