0

I am trying to adapt this code I found online

Sub SaveCopyas2()
Dim newWB As Variant
Dim wb1 As Workbook, wb2 As Workbook

Set wb1 = ActiveWorkbook
If wb1.Saved = False Then MsgBox wb1.FullName, vbInformation, "Workbook Not Saved"

 'Set a filename for new workbook
newWB = Application.GetSaveAsFilename(ActiveWorkbook.FullName, "Excel Files (*.xls), *.xls", , "Set Filename")
If newWB <> False Then wb1.SaveCopyAs (newWB)
End Sub

What this does, is it allows the user to run a macro and save a backup by specifying the location, and the name

What I am trying to do is just have it so that when the macro is run, the file is named "Backup" and the location is C:\

Can anybody help me fix this code to do what I am looking to do?

2
  • 1
    If you solve your own question, you can add the solution as an answer and accept it. Feb 27, 2013 at 15:54
  • Welcome to SO. Please rather move the code that solved you issue from the 'update' in your question, to an answer. And then mark your own answer as correct. This makes it easier for future people with this problem to learn from what you've done. (And take (solved) out of the title. In SO questions are marked as solved with the green tick next to answers, not by editing the title)
    – Dan
    Mar 11, 2013 at 11:15

1 Answer 1

1

(Answered by the OP in a question edit. Moved into a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

The OP wrote:

here is what I got to work.

Sub SaveCopyas2()
Dim newWB As Variant
Dim wb1 As Workbook
Set wb1 = ActiveWorkbook
With wb1
    .SaveCopyAs ("C:\Backup.xlsm")
End With
End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.