WorkBookBeforeClose with personal.xls

leaftye

New Member
Joined
Dec 13, 2005
Messages
21
This code is in a Class Module that's set up to receive events, and it does, but it only see's other workbooks closing and .xla files closing, but never itself (personal.xls).

Code:
Private Sub Monitor_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
  On Error Resume Next
  If Wb.Name = "personal.xls" Then
    With ThisWorkbook
      With .Sheets("Settings")
        Dim tbPosition As Integer
        tbPosition = Application.CommandBars("RobinsonToolbar").Position
        If .Range("ToolbarPosition").Value <> tbPosition Then .Range("ToolbarPosition").Value = tbPosition

      End With
      .Save
    End With
    If ThisWorkbook.Saved = False Then ThisWorkbook.Save
  End If
End Sub

I've also tried putting a copy in ThisWorkbook, but it doesn't ever fire. Can personal.xls see itself closing?


I currently have it set up like this, but every time I close ANY workbook, it saves personal.xls first. Why does it save personal.xls at all?
Code:
Private Sub Monitor_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
'  On Error Resume Next
'  If ActiveWorkbook.Name = ThisWorkbook.Name Then
    With ThisWorkbook
      With .Sheets("Settings")
        Dim tbPosition As Integer
        tbPosition = Application.CommandBars("RobinsonToolbar").Position
        If .Range("ToolbarPosition").Value <> tbPosition Then .Range("ToolbarPosition").Value = tbPosition

      End With
      '.Save
    End With
    If ThisWorkbook.Saved = False Then ThisWorkbook.Save
'  End If
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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