Can't Close Excel

Pullingmyhairout

New Member
Joined
Apr 7, 2016
Messages
29
Good Evening,

Hoping someone can assist me. I have put putting together an excel spread sheet and have been using some VBA code. I am a novice amongst novices and have gathered all the code from around the web and it does exactly as i need and works perfectly.

I used excel 2010 to create my spreadsheet and everything works fine...the issue is if I open the file using excel 2013 (haven't tried 2016) I can not use the x to close the program even if i disable the vba code that hides the ribbon. The only time i'm able to use the X to close out of the program is if i navigate to the very first sheet.

All help is appreciated. thank you.

A link to my excel file is below

https://www.dropbox.com/s/2hlfwefksom3be9/Book8.7.xlsm?dl=0
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
would guess you have something in workbook open event
 
Upvote 0
I'm sure as heck not going to download a file that simply shows me a button to click on !!!
You need to post the code / s you are using, specifically, as mole has suggested the workbook_open event, or any other workbook / worksheet events
 
Upvote 0
I think his problem is this code:
Code:
Application.EnableCancelKey = xlDisabled
When he run a macro button (go to selected sheet), then the code above running and he has set the code in Workbook_Activate & Wokbook_Deactivate too. Just FYI (I am not expert about this) if eveyone here want help this man..hehe;)

NB: the Ribbon is disabled too, so the windows just show minimize, maximize and close button in right corner
 
Upvote 0
my luck....I'd get the WannaCry ransomware :oops:
 
Upvote 0
I used excel 2010 to create my spreadsheet and everything works fine...the issue is if I open the file using excel 2013 (haven't tried 2016) I can not use the x to close the program even if i disable the vba code that hides the ribbon.

Upon opening your workbook, I can click the X to close it in both 2013 and 2016.
 
Upvote 0
I'm sure as heck not going to download a file that simply shows me a button to click on !!!
You need to post the code / s you are using, specifically, as mole has suggested the workbook_open event, or any other workbook / worksheet events

This is the relevant code I am using and the button is to allow the users to navigate to different sheets as work tabs are disabled
Code:
Private Sub Workbook_Open()
Worksheets("Pick One Below").Activate
 
Dim TymeOfDay$
If Time < 0.5 Then
TymeOfDay = "Good Morning !!" & vbCrLf & vbCrLf
ElseIf Time >= 0.5 And Time < 0.75 Then
TymeOfDay = "Good Afternoon !!" & vbCrLf & vbCrLf
Else
TymeOfDay = "Good Evening !!" & vbCrLf & vbCrLf
End If
MsgBox _
TymeOfDay & _
"Message" & vbCrLf & _
"Message," & vbCrLf & _
"Message.", 64, "Box Name:"
End Sub
Private Sub Workbook_Activate()
Application.ScreenUpdating = False
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)" 'False to deactivate
Application.DisplayFormulaBar = False
Application.DisplayStatusBar = Not Application.DisplayStatusBar
ActiveWindow.DisplayWorkbookTabs = False 'True to deactivate
ActiveWindow.DisplayHorizontalScrollBar = False 'True to deactivate
ActiveWindow.DisplayHeadings = False 'True to deactivate
Application.ScreenUpdating = True
Sheets("Released Accident Reports (2)").ScrollArea = "A1:O229"
Sheets("Pick One Below").ScrollArea = "A1"
Sheets("Released Accident Reports (3)").ScrollArea = "A1:O400"
End Sub
 
Private Sub Workbook_Deactivate()
Application.ScreenUpdating = False
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
Application.DisplayFormulaBar = True
Application.DisplayStatusBar = True
Application.ScreenUpdating = True
ActiveWindow.DisplayHorizontalScrollBar = True
ActiveWindow.DisplayWorkbookTabs = True
ActiveWindow.DisplayHeadings = True
Sheets("Released Accident Reports (2)").ScrollArea = ""
Sheets("Pick One Below").ScrollArea = ""
Sheets("Released Accident Reports (3)").ScrollArea = ""
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cancel = True
End Sub
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ThisWorkbook.Saved = True
End Sub
 
Private Sub Worksheet_Activate()
'On worksheet open turn off scroll bars.
 
 With ActiveWindow
 .DisplayHorizontalScrollBar = False
 .DisplayVerticalScrollBar = False
 End With
End Sub
 
Private Sub Worksheet_Deactivate()
'On worksheet open turn off scroll bars.
 
 With ActiveWindow
 .DisplayHorizontalScrollBar = True
 .DisplayVerticalScrollBar = True
 End With
End Sub
 
Last edited by a moderator:
Upvote 0
I think his problem is this code:
Code:
Application.EnableCancelKey = xlDisabled
When he run a macro button (go to selected sheet), then the code above running and he has set the code in Workbook_Activate & Wokbook_Deactivate too. Just FYI (I am not expert about this) if eveyone here want help this man..hehe;)

NB: the Ribbon is disabled too, so the windows just show minimize, maximize and close button in right corner

I deleted that bit of code and still can't close it out
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,273
Members
448,559
Latest member
MrPJ_Harper

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