ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   WorkbookOpen code not executing properly (https://www.excelbanter.com/excel-programming/295798-workbookopen-code-not-executing-properly.html)

SK

WorkbookOpen code not executing properly
 
I have a workbook with a workbook open code as follows :

Private Sub Workbook_Open()
Worksheets("instructions").Activate
Worksheets("instructions").Range("B14").Select
Application.ScreenUpdating = True
If Worksheets("instructions").Range("B14").Value = "" Then
Selection = InputBox("Enter your employee Number!")
Worksheets("instructions").Range("e14").Select
MsgBox "Please note that your Functional Centre is : " &
ThisWorkbook.Worksheets("EE Details Revised").Range("h1").Value ", _
vbOKOnly, "Important information."
Else
Worksheets("Form").Activate
Worksheets("Form").Range("A8").Select
End If
End Sub

Another code in THIS WORKBOOK pane is

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Application.EnableEvents = False
SaveItAs
Application.EnableEvents = True
Cancel = True
End Sub

This calls for a SAVEITAS code which is in Module 1. The SAVEITAS code
has a msgbox for saving with YES,NO,CANCEL.
Yes-it saves the file, No closes without saving and cancel doesnt do
anything.

The problem:
On clicking Yes or cancel, it works fine, but when NO is clicked, the
file closes but when it is opened up next time, it should execute the
workbook open code which it doesnt and therefore does not display the
input box as required by Open code. However, if I exit out of Excel
completely and come back to open the file, then workbook open code
executes.

Any idea why it happens this way. Is there a solution to this problem?

Any help will be greatly appreciated.

Regards
SK

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 04:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com