VBA SaveAs to New Drive, use cell ref as name, and Password Protect document

clvincent

New Member
Joined
Aug 28, 2011
Messages
2
Need help please - Just learning VBA. Trying to write macro that will save file to orig location (not protected), then SAVEAS to new folder location, rename using cell CE3 as name along with time saved, and password protect this document (not original). Macro won't work - what am I doing wrong?
Sub SubmitReport()
'
' SubmitReport Macro
'
'
Sheets("ATB").Select
ActiveSheet.Unprotect
fName = Range("CE3") + " " + Format(Now(), "h:mm;@")
ThisWorkbook.SaveAS "F:\pataccts\SECRETARY\", fName, Password:="myatb",
WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
ActiveWorkbook.Close True
End Sub

<!-- end of AOLMsgPart_1_2c2cc7f0-476b-4900-b76c-82b250d49b36 --><STYLE>.AOLWebSuite .AOLPicturesFullSizeLink { height: 1px; width: 1px; overflow: hidden; } .AOLWebSuite a {color:blue; text-decoration: underline; cursor: pointer} .AOLWebSuite a.hsSig {cursor: default}</STYLE>
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Perhaps this

Code:
Sub SubmitReport()
'
' SubmitReport Macro
'
'
Sheets("ATB").Select
ActiveSheet.Unprotect
fName = Range("CE3").Value & " " & Format(Time, "h-mm") & ".xls"
ThisWorkbook.SaveAs Filename:="F:\pataccts\SECRETARY\" & fName, Password:="myatb", _
WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close True
End Sub
 
Upvote 0
Thank you - I will give it a try tomorrow (at work). I assume the file format would be xlsm however, would it now? macro enabled?
 
Upvote 0
If 2007-2010 then

Code:
Sub SubmitReport()
'
' SubmitReport Macro
'
'
Sheets("ATB").Select
ActiveSheet.Unprotect
fName = Range("CE3").Value & " " & Format(Time, "h-mm") & ".xlsm"
ThisWorkbook.SaveAs Filename:="F:\pataccts\SECRETARY\" & fName, FileFormat:=52, Password:="myatb", _
WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close True
End Sub
 
Upvote 0
Thank you. Have not had a chance to get back to my project yet, but will give it a try & post how it works.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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