Save workbook in 2 places macro

ttratl

Board Regular
Joined
Dec 21, 2004
Messages
168
Hello,

Not sure what's going on with this code...
It was working fine for months, but since I reinstalled Win7 and all my programs, it's gone wrong.
I've altered the locations of where to save the files, as those had changed, but the macro now opens a password dialogue box for a previous file version.

I've been messing around with this for an hour, so I think this is the version that was working previously.
any ideas?
Code:
Sub SaveAs()
'
' SaveAs Macro
         
     ActiveWorkbook.SaveAs FileName:= _
       "E:\Ians documents\_Excel\Cashbook\Cashbook 8 as at " & Format(Date, "dd mm yy") & Format(Time, " hhmm") & ".xlsm", _
      Password:="xxxxxx", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
        
     ActiveWorkbook.SaveCopyAs FileName:= _
       "C:\Users\Ian\Desktop\" & "Cashbook 8 as at " & Format(Now(), "dd mm yy") & Format(Time, " hhmm") & ".xlsm"
   
      
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try

Rich (BB code):
Sub SaveAs()
'
' SaveAs Macro
         
     ActiveWorkbook.SaveAs Filename:= _
       "E:\Ians documents\_Excel\Cashbook\Cashbook 8 as at " & Format(Date, "dd mm yy") & Format(Time, " hhmm") & ".xlsm", _
      FileFormat:=52, Password:="xxxxxx", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
        
     ActiveWorkbook.SaveCopyAs Filename:= _
       "C:\Users\Ian\Desktop\" & "Cashbook 8 as at " & Format(Now(), "dd mm yy") & Format(Time, " hhmm") & ".xlsm"
   
      
End Sub
 
Upvote 0
Thanks Vog.

I appear to have more serious issues, in that i cannot fire this macro from a QAT button (Excel 2010), which may mean my original macro was ok anyway.
I've ended up with this code:
Code:
Sub SaveInTwoPlaces()

    ChDir "E:\Ians documents\_Excel\Cashbook"
    ActiveWorkbook.SaveAs FileName:= _
        "E:\Ians documents\_Excel\Cashbook\Cashbook 8 as at " & Format(Date, "dd mm yy") & Format(Time, " hhmm") & ".xlsm", FileFormat _
        :=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

    ChDir "C:\Users\Ian\Desktop"
    ActiveWorkbook.SaveAs FileName:= _
        "C:\Users\Ian\Desktop\Cashbook 8 as at " & Format(Date, "dd mm yy") & Format(Time, " hhmm") & ".xlsm", FileFormat:= _
        xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

End Sub
Which works fine, but still won't fire from a QAT button. I think this is something to look at on another day. There seems to be some info on a few Google searches to look at.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

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