I am pulling my hair out in big clumps trying to resolve this. When the macro fails and I get the error message in the Title block it highlights the following line;
Range("VERSION").FormulaR1C1 = TempVersion
I assume that I've not properly defined something but I'm wearing my Captain ADHD hat and not seeing the issue at the moment. I fixed a couple of other things but this one eludes me.
I tried to identify the specific sheet I want the info to end up in with Sheets.select ("Version Control") but no help. I've spent an hour plus digging through the web but haven't resolved the issue yet.
Any suggestions, input or brickbats gratefully received.
Thanks much!
Bill
Range("VERSION").FormulaR1C1 = TempVersion
I assume that I've not properly defined something but I'm wearing my Captain ADHD hat and not seeing the issue at the moment. I fixed a couple of other things but this one eludes me.
I tried to identify the specific sheet I want the info to end up in with Sheets.select ("Version Control") but no help. I've spent an hour plus digging through the web but haven't resolved the issue yet.
Any suggestions, input or brickbats gratefully received.
Thanks much!
Bill
Code:
Sub TempSave()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim TempVersion As String
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sourcewb = ActiveWorkbook
'Force the file extension to remain as Excel macro enabled
FileExtStr = ".xlsm": FileFormatNum = 52
ActiveSheet.Unprotect
TempFilePath = "H:\Estimator"
TempVersion = Format(Now, "yy-mm-dd hh-mm-ss")
TempFileName = "Temp " & Range("Estimator") & " " & TempVersion
Sheets.Select ("Version Control")
Range("VERSION").FormulaR1C1 = TempVersion
ActiveSheet.Protect
With Sourcewb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
End With
MsgBox "New version saved as " & TempFilePath & TempFileName
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub