Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following procedure does not trigger when I open the workbook.
I tried both as read only and NOT read only. It works great when I step thru it (F8). It would seem to me to be a problem in the This Workbook Module, but I don't really know what to look for. THIS WORKBOOK Option Explicit Private Sub Workbook_Open() ' IF File is Read Only, Call SaveAs_Message to 'force' New File Name ' If NOT Read Only, then exit procedure If ThisWorkbook.ReadOnly = True _ Then Call SaveAs_Message _ Else: Exit Sub End Sub MODULE 1 Option Explicit Sub SaveAs_Message() Dim Msg As String, Title As String Dim Config As Integer, Ans As Integer Msg = " This is a 'READ ONLY' File" ..................... blah, blah, blah, Msg = Msg & "Selecting CANCEL will STOP this Process and CLOSE this file " Title = "XXXXXXX W A R N I N G ! !" Config = vbOKCancel + vbCritical = vbButton1 Ans = MsgBox(Msg, Config, Title) If Ans = vbOK Then Call SaveAs_Process End Sub Sub SaveAs_Process() ' Bring up the Save As Dialog Box Application.Dialogs(xlDialogSaveAs).Show End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It works on my computer.
Workbook_open is fired. Put any MsgBox to Workbook_Open to see if it is fired. Copy code as a text to a new file and check. Do you have auto_open macro somewhere? BEEJAY wrote: The following procedure does not trigger when I open the workbook. I tried both as read only and NOT read only. It works great when I step thru it (F8). It would seem to me to be a problem in the This Workbook Module, but I don't really know what to look for. THIS WORKBOOK Option Explicit Private Sub Workbook_Open() ' IF File is Read Only, Call SaveAs_Message to 'force' New File Name ' If NOT Read Only, then exit procedure If ThisWorkbook.ReadOnly = True _ Then Call SaveAs_Message _ Else: Exit Sub End Sub MODULE 1 Option Explicit Sub SaveAs_Message() Dim Msg As String, Title As String Dim Config As Integer, Ans As Integer Msg = " This is a 'READ ONLY' File" ..................... blah, blah, blah, Msg = Msg & "Selecting CANCEL will STOP this Process and CLOSE this file " Title = "XXXXXXX W A R N I N G ! !" Config = vbOKCancel + vbCritical = vbButton1 Ans = MsgBox(Msg, Config, Title) If Ans = vbOK Then Call SaveAs_Process End Sub Sub SaveAs_Process() ' Bring up the Save As Dialog Box Application.Dialogs(xlDialogSaveAs).Show End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As a first check I would reset my events.
sub ResetEvent Application.enableEvents = true end sub Run the above procedure and then try re-opening your spreadsheet. If anywhere in your world you have disabled events without re-enabling them again then your events will not fire until you reset them... This is why you should always have an error handler to reset your events in case some of your code crashes. You also want to be carefull debugging, that you reset events if you prematurely end your code. The other way to loose your events is if you have an MDX Addin (from Microsoft I believe) called "Cube Analysis" which can turn your events off without turning them back on again... -- HTH... Jim Thomlinson "BEEJAY" wrote: The following procedure does not trigger when I open the workbook. I tried both as read only and NOT read only. It works great when I step thru it (F8). It would seem to me to be a problem in the This Workbook Module, but I don't really know what to look for. THIS WORKBOOK Option Explicit Private Sub Workbook_Open() ' IF File is Read Only, Call SaveAs_Message to 'force' New File Name ' If NOT Read Only, then exit procedure If ThisWorkbook.ReadOnly = True _ Then Call SaveAs_Message _ Else: Exit Sub End Sub MODULE 1 Option Explicit Sub SaveAs_Message() Dim Msg As String, Title As String Dim Config As Integer, Ans As Integer Msg = " This is a 'READ ONLY' File" ..................... blah, blah, blah, Msg = Msg & "Selecting CANCEL will STOP this Process and CLOSE this file " Title = "XXXXXXX W A R N I N G ! !" Config = vbOKCancel + vbCritical = vbButton1 Ans = MsgBox(Msg, Config, Title) If Ans = vbOK Then Call SaveAs_Process End Sub Sub SaveAs_Process() ' Bring up the Save As Dialog Box Application.Dialogs(xlDialogSaveAs).Show End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do you open this workbook?
If you're opening via another macro that uses a shortcut key, remove the shift key from that shortcut key combination. BEEJAY wrote: The following procedure does not trigger when I open the workbook. I tried both as read only and NOT read only. It works great when I step thru it (F8). It would seem to me to be a problem in the This Workbook Module, but I don't really know what to look for. THIS WORKBOOK Option Explicit Private Sub Workbook_Open() ' IF File is Read Only, Call SaveAs_Message to 'force' New File Name ' If NOT Read Only, then exit procedure If ThisWorkbook.ReadOnly = True _ Then Call SaveAs_Message _ Else: Exit Sub End Sub MODULE 1 Option Explicit Sub SaveAs_Message() Dim Msg As String, Title As String Dim Config As Integer, Ans As Integer Msg = " This is a 'READ ONLY' File" ..................... blah, blah, blah, Msg = Msg & "Selecting CANCEL will STOP this Process and CLOSE this file " Title = "XXXXXXX W A R N I N G ! !" Config = vbOKCancel + vbCritical = vbButton1 Ans = MsgBox(Msg, Config, Title) If Ans = vbOK Then Call SaveAs_Process End Sub Sub SaveAs_Process() ' Bring up the Save As Dialog Box Application.Dialogs(xlDialogSaveAs).Show End Sub -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you All:
Jim: Turns out you hit the nail right on the head. NONE of my codes have error handling, etc. in them. This is something I'm going to have to learn about and include in each code. Thanks for the eye opener. "Dave Peterson" wrote: How do you open this workbook? If you're opening via another macro that uses a shortcut key, remove the shift key from that shortcut key combination. BEEJAY wrote: The following procedure does not trigger when I open the workbook. I tried both as read only and NOT read only. It works great when I step thru it (F8). It would seem to me to be a problem in the This Workbook Module, but I don't really know what to look for. THIS WORKBOOK Option Explicit Private Sub Workbook_Open() ' IF File is Read Only, Call SaveAs_Message to 'force' New File Name ' If NOT Read Only, then exit procedure If ThisWorkbook.ReadOnly = True _ Then Call SaveAs_Message _ Else: Exit Sub End Sub MODULE 1 Option Explicit Sub SaveAs_Message() Dim Msg As String, Title As String Dim Config As Integer, Ans As Integer Msg = " This is a 'READ ONLY' File" ..................... blah, blah, blah, Msg = Msg & "Selecting CANCEL will STOP this Process and CLOSE this file " Title = "XXXXXXX W A R N I N G ! !" Config = vbOKCancel + vbCritical = vbButton1 Ans = MsgBox(Msg, Config, Title) If Ans = vbOK Then Call SaveAs_Process End Sub Sub SaveAs_Process() ' Bring up the Save As Dialog Box Application.Dialogs(xlDialogSaveAs).Show End Sub -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to: Open closed workbook/Search data tables/Return data to open workbook | Excel Discussion (Misc queries) | |||
how do i open a data workbook when i open a timesheet workbook | Excel Discussion (Misc queries) | |||
Workbook Open Event not triggering | Excel Programming | |||
workbooks.open without triggering event | Excel Programming | |||
How do you program so that Workbook B cannot be open unless Workbook A is open? Plus I need to validation | Excel Programming |