ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Private Sub Workbook_Open() & Workbook_BeforeClose(cancel As Boolean) (https://www.excelbanter.com/excel-programming/373379-private-sub-workbook_open-workbook_beforeclose-cancel-boolean.html)

halibut

Private Sub Workbook_Open() & Workbook_BeforeClose(cancel As Boolean)
 
Private Sub Workbook_BeforeClose(cancel As Boolean)
Application.CommandBars("Pack tool bar").Visible = False
End Sub

Private Sub Workbook_Open()
Sheet1.Range("e3").Value = Sheet1.Range("ap3").Value
Application.CommandBars("Pack tool bar").Visible = True
Application.CommandBars("Pack tool
bar").Controls("Import").OnAction = "Import"
Application.CommandBars("Pack tool bar").Controls("Print
Pack").OnAction = "Printmacro"
Application.CommandBars("Pack tool bar").Controls("Roll
TB").OnAction = "Periodchange"
Application.CommandBars("Pack tool bar").Controls("Reset
Pack").OnAction = "Reset"
End Sub

These two routines do not work (they work on other installations of
excel on other computers) when the workbook is opened. In fact any code
I try and run from the Workbook_Open() & Workbook_BeforeClose(cancel As
Boolean) does not work on my installation of Excel 2003 it only works
if i run it manually.

Does any one have any ideas why? Are there any settings I have
inadvertently changed?


kassie

Private Sub Workbook_Open() & Workbook_BeforeClose(cancel As Boole
 
Did you put this code in a module, or in This Workbook? The latter is the
right place

"halibut" wrote:

Private Sub Workbook_BeforeClose(cancel As Boolean)
Application.CommandBars("Pack tool bar").Visible = False
End Sub

Private Sub Workbook_Open()
Sheet1.Range("e3").Value = Sheet1.Range("ap3").Value
Application.CommandBars("Pack tool bar").Visible = True
Application.CommandBars("Pack tool
bar").Controls("Import").OnAction = "Import"
Application.CommandBars("Pack tool bar").Controls("Print
Pack").OnAction = "Printmacro"
Application.CommandBars("Pack tool bar").Controls("Roll
TB").OnAction = "Periodchange"
Application.CommandBars("Pack tool bar").Controls("Reset
Pack").OnAction = "Reset"
End Sub

These two routines do not work (they work on other installations of
excel on other computers) when the workbook is opened. In fact any code
I try and run from the Workbook_Open() & Workbook_BeforeClose(cancel As
Boolean) does not work on my installation of Excel 2003 it only works
if i run it manually.

Does any one have any ideas why? Are there any settings I have
inadvertently changed?



halibut

Private Sub Workbook_Open() & Workbook_BeforeClose(cancel As Boole
 
the code is in "This Workbook"

kassie wrote:
Did you put this code in a module, or in This Workbook? The latter is the
right place

"halibut" wrote:

Private Sub Workbook_BeforeClose(cancel As Boolean)
Application.CommandBars("Pack tool bar").Visible = False
End Sub

Private Sub Workbook_Open()
Sheet1.Range("e3").Value = Sheet1.Range("ap3").Value
Application.CommandBars("Pack tool bar").Visible = True
Application.CommandBars("Pack tool
bar").Controls("Import").OnAction = "Import"
Application.CommandBars("Pack tool bar").Controls("Print
Pack").OnAction = "Printmacro"
Application.CommandBars("Pack tool bar").Controls("Roll
TB").OnAction = "Periodchange"
Application.CommandBars("Pack tool bar").Controls("Reset
Pack").OnAction = "Reset"
End Sub

These two routines do not work (they work on other installations of
excel on other computers) when the workbook is opened. In fact any code
I try and run from the Workbook_Open() & Workbook_BeforeClose(cancel As
Boolean) does not work on my installation of Excel 2003 it only works
if i run it manually.

Does any one have any ideas why? Are there any settings I have
inadvertently changed?




Jim Cone

Private Sub Workbook_Open() & Workbook_BeforeClose(cancel As Boolean)
 
Try running this line of code and see if turns things back on...
Application.EnableEvents = True
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"halibut"
wrote in message
Private Sub Workbook_BeforeClose(cancel As Boolean)
Application.CommandBars("Pack tool bar").Visible = False
End Sub

Private Sub Workbook_Open()
Sheet1.Range("e3").Value = Sheet1.Range("ap3").Value
Application.CommandBars("Pack tool bar").Visible = True
Application.CommandBars("Pack tool
bar").Controls("Import").OnAction = "Import"
Application.CommandBars("Pack tool bar").Controls("Print
Pack").OnAction = "Printmacro"
Application.CommandBars("Pack tool bar").Controls("Roll
TB").OnAction = "Periodchange"
Application.CommandBars("Pack tool bar").Controls("Reset
Pack").OnAction = "Reset"
End Sub

These two routines do not work (they work on other installations of
excel on other computers) when the workbook is opened. In fact any code
I try and run from the Workbook_Open() & Workbook_BeforeClose(cancel As
Boolean) does not work on my installation of Excel 2003 it only works
if i run it manually.
Does any one have any ideas why? Are there any settings I have
inadvertently changed?


halibut

Private Sub Workbook_Open() & Workbook_BeforeClose(cancel As Boolean)
 
Thanks Jim,

Application.EnableEvents = True, did the trick!!

Jim Cone wrote:
Try running this line of code and see if turns things back on...
Application.EnableEvents = True
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"halibut"
wrote in message
Private Sub Workbook_BeforeClose(cancel As Boolean)
Application.CommandBars("Pack tool bar").Visible = False
End Sub

Private Sub Workbook_Open()
Sheet1.Range("e3").Value = Sheet1.Range("ap3").Value
Application.CommandBars("Pack tool bar").Visible = True
Application.CommandBars("Pack tool
bar").Controls("Import").OnAction = "Import"
Application.CommandBars("Pack tool bar").Controls("Print
Pack").OnAction = "Printmacro"
Application.CommandBars("Pack tool bar").Controls("Roll
TB").OnAction = "Periodchange"
Application.CommandBars("Pack tool bar").Controls("Reset
Pack").OnAction = "Reset"
End Sub

These two routines do not work (they work on other installations of
excel on other computers) when the workbook is opened. In fact any code
I try and run from the Workbook_Open() & Workbook_BeforeClose(cancel As
Boolean) does not work on my installation of Excel 2003 it only works
if i run it manually.
Does any one have any ideas why? Are there any settings I have
inadvertently changed?




All times are GMT +1. The time now is 10:56 PM.

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