Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Custom Menus Error at Close

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 procedu
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Custom Menus Error at Close

Hello,

I couldn't locate your problem but I 'd like to make a note:
The event Workbook_BeforeClose occurs before the event Workbook_Deactivate.
So if you delete your menues in BeforeClose there will be nothing to hide in
BeforeClose.
Or I might have overlooked something here .... :)

Herbert

"CyberBuzzard" wrote:

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 procedu
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Custom Menus Error at Close

Try compiling the code. In the VBE select Debug - Compile VBA Project. The
syntax error should be highlighted. Cances are you have called a procedure
without supplying one of the argments of the procedure. Probably one of these
Call DeleteMenuSample
Call DeleteMenuGeneral
Call DeleteMenuFACILITIES
Call DeleteMenuCostCats

As a complete aside your variable msg should be declared as long. Not that
it will make a big difference in this case but it is a bit mroe efficient.

--
HTH...

Jim Thomlinson


"CyberBuzzard" wrote:

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 procedu
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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Custom Menus Error at Close

Thank you Herbert.

I had noticed your point about the sequence of events. Now, how do I keep my
menus from appearing in other workbooks and at the same time avoid the Error
message?
--
Any help will be appreciated.

Regards,

CyberBuzzard


"Herbert" wrote:

Hello,

I couldn't locate your problem but I 'd like to make a note:
The event Workbook_BeforeClose occurs before the event Workbook_Deactivate.
So if you delete your menues in BeforeClose there will be nothing to hide in
BeforeClose.
Or I might have overlooked something here .... :)

Herbert

"CyberBuzzard" wrote:

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 procedu
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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Custom Menus Error at Close

Thank you Jim.

I runned the compiling but to no avail. I have noticed that the Compile
VBAProject utility sometimes misses badly on obvious errors I painfully find
later when an error appears.
--
Any help will be appreciated.

Regards,

CyberBuzzard


"Jim Thomlinson" wrote:

Try compiling the code. In the VBE select Debug - Compile VBA Project. The
syntax error should be highlighted. Cances are you have called a procedure
without supplying one of the argments of the procedure. Probably one of these
Call DeleteMenuSample
Call DeleteMenuGeneral
Call DeleteMenuFACILITIES
Call DeleteMenuCostCats

As a complete aside your variable msg should be declared as long. Not that
it will make a big difference in this case but it is a bit mroe efficient.

--
HTH...

Jim Thomlinson


"CyberBuzzard" wrote:

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 procedu
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom menus Stephen[_21_] Excel Programming 3 February 13th 05 07:25 PM
Custom faces for custom menus/commandbars Stu Valentine Excel Programming 1 September 17th 04 04:28 AM
custom menus Bob Phillips[_6_] Excel Programming 3 May 6th 04 10:31 PM
Custom menus Lee Excel Programming 4 November 12th 03 11:53 PM
Custom Menus Andy Wiggins[_2_] Excel Programming 0 September 19th 03 06:10 AM


All times are GMT +1. The time now is 07:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"