Workbook Open Events do not run

davidam

Active Member
Joined
May 28, 2010
Messages
497
Office Version
  1. 2021
Platform
  1. Windows
Hello,
I am trying to make workbook open events run but they will not.

I run a macro from another sheet:
Code:
Public Sub Open_Chart()
Application.EnableEvents = True
Workbooks.Open Filename:="C:\CLIPr\CCharts.xls"
End Sub

So there should be no problem with events running.

This is the Workbook Open macro
Code:
Private Sub Workbook_Open()
Worksheets("CR").Activate
ActiveSheet.Unprotect Password:=PW
ActiveWindow.FreezePanes = False
Range("A5").Select
ActiveWindow.ScrollRow = 1
Application.ScreenUpdating = True
ActiveSheet.Protect Password:=PW
End Sub

Any suggestions?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Did you put the Workbook_Open code in the ThisWorkbook module of the file being opened?
 
Upvote 0
I tried

Rich (BB code):
Public Sub Open_Chart()
Application.EnableEvents = True
Workbooks.Open Filename:="C:\Test\Book1.xlsm"
End Sub

to open a file with this

Rich (BB code):
Private Sub Workbook_Open()
Worksheets("CR").Activate
ActiveSheet.Unprotect Password:="PW"
ActiveWindow.FreezePanes = False
Range("A5").Select
ActiveWindow.ScrollRow = 1
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="PW"
End Sub

and the event code ran.
 
Upvote 0
I tried my code on a test workbook and it opened with or without the "".
I only have the following other events in the workbook:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect Password:=PW
If Not Intersect(Target, Range("R8:R10,R12:R14")) Is Nothing Then
 If Target = "o" Then
 Target = "R"
 ActiveCell.Select
 With Selection.Font
        .Name = "Wingdings 2"
        .Size = 10
        .Bold = True
   End With
   With Selection
         .HorizontalAlignment = xlRight
   End With
 Else: Target = "o"
 ActiveCell.Select
  With Selection.Font
        .Name = "Wingdings"
        .Size = 10
        .Bold = False
  End With
   With Selection
         .HorizontalAlignment = xlRight
   End With
 End If
End If
Application.ScreenUpdating = True
If ActiveCell.Column = 18 Then
Application.SendKeys "{TAB}"
End If
ActiveSheet.Protect Password:=PW
End Sub
This workbooks was modified and trimmed down from a much larger workbook...I wonder if there could be some unseen bug that I will only get rid of if I start again...I had to do that once before when I could not get rid of a "only Comments may appear after End Sub".
 
Upvote 0
I fear this is what I must do...sigh... a lot of work. Will report the result for any who might be interested.
 
Upvote 0
Peter, you have saved the day for me yet again!
I tried adding the quotation marks to the password and I got an error on message on Workbook Open...thus it must be firing. It is old programming that is the problem because the worksheet in question was hidden...just needed to put unhide into the open event code and it all works fine.
Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,470
Members
452,915
Latest member
hannnahheileen

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