Reputation: 133
I currently have 2 checkboxes, one that says "Summary" and the other "Breakdown". When the user checks either one or both of the boxes, it needs to open another excel file with name "Summary Template" and "Breakdown Template" respectively and eventually "Save As" NAME (ID). How do I go about doing so? Thanks in advance!
If Summary Then
Debug.Print "You Checked Summary"
MyPath = "C:\Users\valerie\Desktop\"Summary Template.xlsx"
Workbooks.Open (MyPath)
'Am stuck here on how to save as file
ElseIf Breakdown Then
Debug.Print "You Checked Breakdown"
MyPath = "C:\Users\valerie\Desktop\"Breakdown Template.xlsx"
Workbooks.Open (MyPath)
ElseIf Summary = 0 And Breakdown = 0 Then
MsgBox "Please Select Report Type"
End If
Upvotes: 1
Views: 226
Reputation: 57743
Do the following and read SaveAs method:
Dim wb As Workbook
If Summary Then
Debug.Print "You Checked Summary"
MyPath = "C:\Users\valerie\Desktop\Summary Template.xlsx"
Set wb = Workbooks.Open(MyPath) 'set workbook to a variable that you can use to access it
wb.SaveAs FileName:="C:\Users\valerie\Desktop\XXXX.xlsx", FileFormat:=xlOpenXMLWorkbook
'check documentation for how to use it.
ElseIf Breakdown Then
Debug.Print "You Checked Breakdown"
MyPath = "C:\Users\valerie\Desktop\Breakdown Template.xlsx"
Set wb = Workbooks.Open(MyPath)
ElseIf Summary = 0 And Breakdown = 0 Then
MsgBox "Please Select Report Type"
End If
Note that ther was an additional "
between your path and file name (in your question) that has to be removed.
Upvotes: 1