Work book open issues

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
569
Office Version
  1. 365
Platform
  1. 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.

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
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top