rjplante
Well-known Member
- Joined
- Oct 31, 2008
- Messages
- 569
- Office Version
- 365
- Platform
- Windows
I have the code listed below and when it opens up the file it renames the file from "Change Order Template" to "Change Order Template1". I cannot figure out why it is adding the one to the file name, but it is still not adding a 1 to the cell value, or displaying the message box.
I have turned off the notification control lines as I thought this was automatically saving the file with the 1 appended as it did not want to overwrite the existing file. In the end I do not want notifications, I just want the existing file to be overwritten with the serial number changed so that the next time the file is opened, it will continue the serial number sequence.
I have turned off the notification control lines as I thought this was automatically saving the file with the 1 appended as it did not want to overwrite the existing file. In the end I do not want notifications, I just want the existing file to be overwritten with the serial number changed so that the next time the file is opened, it will continue the serial number sequence.
Code:
Private Sub Workbook_Open()
Debug.Assert False
If ThisWorkbook.FullName = ThisWorkbook.Path & "\Change Order Template.xlt" Then
i = MsgBox("This is a new workbook, would you like to update the serial number?.", vbYesNo + vbExclamation + vbDefaultButton2)
If i = 7 Then 'NO
Exit Sub
ElseIf i = 6 Then 'YES
Sheets("Change Order").Range("W3").Value = Sheets("Change Order").Range("BF3").Value + 1
'Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\Change Order Template.xlt"
'Application.DisplayAlerts = True
Range("D5").Select
End If
End If
End Sub