Work book open issues

rjplante

Active Member
Joined
Oct 31, 2008
Messages
489
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
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Watch MrExcel Video

Forum statistics

Threads
1,122,372
Messages
5,595,787
Members
414,021
Latest member
whyjaydee

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
Top