code that might be causing error - please review and comment

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

below are sections of code that might me causing my error when I close excel

THIS IS IN MY WORKBOOK MODUL

Private Sub Workbook_BeforeClose(Cancel As Boolean
Call DeleteMenuBa
End Su

FOLLOWING ARE PORTIONS OF MY MENU MODULE RELATED TO DELETING THE MENU BAR AND THE WORKBOOK_BEFORE CLOSE COD

' Delete menu bar if it exist
Call DeleteMenuBa
' Add a new menu ite
Set NewItem = NewMenu.Controls.Add(Type:=msoControlButton
With NewIte
.Caption = "&Restore Normal Menu
.OnAction = "DeleteMenuBar
End Wit
End Su

Sub DeleteMenuBar(
On Error Resume Nex
CommandBars("MyMenuBar").Delet
On Error GoTo
End Su

please advise if you can see if any of this code could be causing an error to occur when i try to close my excel file without saving (X in top right corner) or attempting to "save as

Thanks
 
It looks okay. Where does that second block of code reside? What error do
you get?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

bruce forster said:
below are sections of code that might me causing my error when I close excel;

THIS IS IN MY WORKBOOK MODULE

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call DeleteMenuBar
End Sub

FOLLOWING ARE PORTIONS OF MY MENU MODULE RELATED TO DELETING THE MENU BAR
AND THE WORKBOOK_BEFORE CLOSE CODE
' Delete menu bar if it exists
Call DeleteMenuBar
' Add a new menu item
Set NewItem = NewMenu.Controls.Add(Type:=msoControlButton)
With NewItem
.Caption = "&Restore Normal Menu"
.OnAction = "DeleteMenuBar"
End With
End Sub

Sub DeleteMenuBar()
On Error Resume Next
CommandBars("MyMenuBar").Delete
On Error GoTo 0
End Sub

please advise if you can see if any of this code could be causing an error
to occur when i try to close my excel file without saving (X in top right
corner) or attempting to "save as"
 
Hi
code looks o.k.
What exact error do you receive (and in which line)

--
Regards
Frank Kabel
Frankfurt, Germany

bruce forster said:
below are sections of code that might me causing my error when I close excel;

THIS IS IN MY WORKBOOK MODULE

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call DeleteMenuBar
End Sub

FOLLOWING ARE PORTIONS OF MY MENU MODULE RELATED TO DELETING THE MENU
BAR AND THE WORKBOOK_BEFORE CLOSE CODE
' Delete menu bar if it exists
Call DeleteMenuBar
' Add a new menu item
Set NewItem = NewMenu.Controls.Add(Type:=msoControlButton)
With NewItem
.Caption = "&Restore Normal Menu"
.OnAction = "DeleteMenuBar"
End With
End Sub

Sub DeleteMenuBar()
On Error Resume Next
CommandBars("MyMenuBar").Delete
On Error GoTo 0
End Sub

please advise if you can see if any of this code could be causing an
error to occur when i try to close my excel file without saving (X in
top right corner) or attempting to "save as"
 
When i try to close my excel file i often times get an error message "An error has been encountered and needs to close...: and there is an option box to restart excel. Any ideas why this happens?

There is no prompt to debug. A pop up box displays with text that says "An error has been encountered and needs to close..."

The second block of code is in a module that controls a custom menu bar. Could there be a problem with Sub DeleteMenuBar() code?

Any suggestions are appreciated.
 
When i try to close my excel file i often times get an error message "An error has been encountered and needs to close...: and there is an option box to restart excel. Any ideas why this happens?

There is no prompt to debug. A pop up box displays with text that says "An error has been encountered and needs to close..."

Any suggestions are appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top