LuminaryXion
New Member
- Joined
- Jul 23, 2012
- Messages
- 6
Good day!
I an not really a coder, but somewhat of a power user. I hope to be able to accomplish some fancy coding with a little help from generous geniuses like yourselves.
I'm coding a macro in VBA to save a copy of the Active Workbook with a new name based on some variables within the spreadsheet itself. I seem to be grabbing the variables correctly but when it gets to the saveas event, I get The above described Error 400 (Error 1004 in Debug mode).
Please find the problem code, with a bit of the surrounding code for reference below:
Please note that I have commented out my error handler specifically so as to be able to see the error in debug mode. That's why that's there.
I've been wracking my brain all day and I can't figure out why it's not working. I'd appreciate any help you can provide.
Thank you.
I an not really a coder, but somewhat of a power user. I hope to be able to accomplish some fancy coding with a little help from generous geniuses like yourselves.
I'm coding a macro in VBA to save a copy of the Active Workbook with a new name based on some variables within the spreadsheet itself. I seem to be grabbing the variables correctly but when it gets to the saveas event, I get The above described Error 400 (Error 1004 in Debug mode).
Please find the problem code, with a bit of the surrounding code for reference below:
Code:
Public Sub SaveLessonRecordFileName()
' // Specifying my variables
Dim NewFileName As Variant
' On Error GoTo ErrorHandler
' // Grabbing some variables from the workbook to populate my file name
NewFileName = ActiveWorkbook.Path & Application.PathSeparator & Range("E5").Value & " " & Range("E4").Value & " Attendance"
' // "Cancel" button case loop
If NewFileName = False Then
MsgBox "The save have been canceled."
Exit Sub
End If
' // Time to save the world! Or just my new workbook...
With ActiveWorkbook
.SaveAs Filename:=NewFileName & ".xls", FileFormat:=xlNormal
End With
End Sub
Please note that I have commented out my error handler specifically so as to be able to see the error in debug mode. That's why that's there.
I've been wracking my brain all day and I can't figure out why it's not working. I'd appreciate any help you can provide.
Thank you.