C
CyberBuzzard
I have an error appearing when I close the workbook with my VBA code. I was
able to hide the custom menus I made for my application when, for example, I
open a new workbook. The problem arises when I close the workbook either with
the File|Close menu or with Alt|F4. The error “Invalid procedure call or
argument†appears every time I close the workbook.
In the “ThisWorkBook†Module I have written the following:
Private Sub Workbook_Open()
Call SampleMenu
Call GeneralFinMenu
Call FACILITIESMenu
Call ConstructionMenu
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Msg As Variant
Application.ScreenUpdating = False
If Not Me.Saved Then
Msg = MsgBox(Space(5) & vbCrLf & _
"Do you want to save the changes you made to " & _
Me.Name & "?" & _
vbCrLf & vbCrLf & vbCrLf, vbQuestion + vbYesNoCancel, _
"BOUNDARY SOFTWAREâ€)
If Msg = vbYes Then
Me.Save
ElseIf Msg = vbNo Then
Me.Saved = True
ElseIf Msg = vbCancel Then
Cancel = True
Exit Sub
End If
End If
Call DeleteMenuSample
Call DeleteMenuGeneral
Call DeleteMenuFACILITIES
Call DeleteMenuCostCats
End Sub
Private Sub WorkBook_Activate()
Call ShowMenus
End Sub
Private Sub WorkBook_Deactivate()
Call HideMenus
End Sub
On a standard Module I have the following procedure:
Sub HideMenus()
CommandBars(1).Controls("Sample Data").Visible = False
CommandBars(1).Controls("General FINANCIAL").Visible = False
CommandBars(1).Controls("FACILITIES").Visible = False
CommandBars(1).Controls("CONSTRUCTION Data").Visible = False
End Sub
This last procedure is the one marked by the error at closing.
--
Any help will be appreciated.
Regards,
CyberBuzzard
able to hide the custom menus I made for my application when, for example, I
open a new workbook. The problem arises when I close the workbook either with
the File|Close menu or with Alt|F4. The error “Invalid procedure call or
argument†appears every time I close the workbook.
In the “ThisWorkBook†Module I have written the following:
Private Sub Workbook_Open()
Call SampleMenu
Call GeneralFinMenu
Call FACILITIESMenu
Call ConstructionMenu
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Msg As Variant
Application.ScreenUpdating = False
If Not Me.Saved Then
Msg = MsgBox(Space(5) & vbCrLf & _
"Do you want to save the changes you made to " & _
Me.Name & "?" & _
vbCrLf & vbCrLf & vbCrLf, vbQuestion + vbYesNoCancel, _
"BOUNDARY SOFTWAREâ€)
If Msg = vbYes Then
Me.Save
ElseIf Msg = vbNo Then
Me.Saved = True
ElseIf Msg = vbCancel Then
Cancel = True
Exit Sub
End If
End If
Call DeleteMenuSample
Call DeleteMenuGeneral
Call DeleteMenuFACILITIES
Call DeleteMenuCostCats
End Sub
Private Sub WorkBook_Activate()
Call ShowMenus
End Sub
Private Sub WorkBook_Deactivate()
Call HideMenus
End Sub
On a standard Module I have the following procedure:
Sub HideMenus()
CommandBars(1).Controls("Sample Data").Visible = False
CommandBars(1).Controls("General FINANCIAL").Visible = False
CommandBars(1).Controls("FACILITIES").Visible = False
CommandBars(1).Controls("CONSTRUCTION Data").Visible = False
End Sub
This last procedure is the one marked by the error at closing.
--
Any help will be appreciated.
Regards,
CyberBuzzard