PNG32 PNG32 PNG32 PNG32
PNG32
Forum Excel, VBA, VSTO, Exceltips, Excelhj�lp PNG32 drivs av Excelspecialisten    Logga in     English
PNG32
PNG32 PNG32
PNG32

Logga in

PNG32

Du är inte inloggad. Logga in eller registrera dig för att skriva inlägg eller svara på inlägg.

För frågor om forumet, kontakta oss på webmaster@excelforum.se

PNG32 PNG32
PNG32 PNG32
PNG32

Excelforum

PNG32

 
ForumForumDiskussionerDiskussionerVBAVBAAvsluta Excel...Avsluta Excel...
Föregående Föregående
 
Nästa Nästa
Nytt inlägg
 2020-10-17 10:57
 
Hej, jag använder Windows10 och nu upptäcker jag efter ngn uppdatering att Excel inte avslutas helt efter att jag gett kommandot Application.Quit ??
Excel stänger ner men det blir kvar en ruta som jag manuellt behöver avsluta, med typ Alt + F4

Är det någon här i forumet som har en lösning för detta ??

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.ScreenUpdating = False

If Y = False Then

X = MsgBox("Avsluta / Spara", vbYesNo, "Spara ??")

If X = 6 Then

Y = True
ActiveWorkbook.Close SaveChanges:=True

End If

End If

ActiveWindow.Zoom = 100

ActiveWorkbook.Windows.Application.DisplayFullScreen = False

ActiveWindow.DisplayHeadings = True
Application.DisplayFormulaBar = True

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
End With

With ActiveWorkbook
.RunAutoMacros xlAutoClose
.Close
End With

Application.Quit

End Sub
Nytt inlägg
 2020-10-22 07:36
 
Hittade på nätet följande från Microsoft...

"How to suppress Save Changes" prompt when you close a workbook in Excel

Example 1: Close the workbook without saving changes
To force a workbook to close without saving any changes, type the following code in a Visual Basic module of that workbook:


Sub Auto_Close()

ThisWorkbook.Saved = True

End Sub

The DisplayAlerts property of the program can be used for the same purpose. For example, the following macro turns DisplayAlerts off, closes the active workbook without saving changes, and then turns DisplayAlerts on again.


Sub CloseBook()

Application.DisplayAlerts = False

ActiveWorkbook.Close

Application.DisplayAlerts = True

End Sub

You can also use the SaveChanges argument of the Close method.

The following macro closes the workbook without saving changes:


Sub CloseBook2()

ActiveWorkbook.Close savechanges:=False

End Sub

Example 2: Close the workbook and save the changes
To force a workbook to save changes, type the following code in a Visual Basic module of that workbook:


Sub Auto_Close()

If ThisWorkbook.Saved = False Then

ThisWorkbook.Save End If

End Sub

This subprocedure checks to see if the file Saved property has been set to False. If so, the workbook has been changed since the last save, and those changes are saved.
Föregående Föregående
 
Nästa Nästa
ForumForumDiskussionerDiskussionerVBAVBAAvsluta Excel...Avsluta Excel...

PNG32 PNG32
Excelforum drivs av Excelspecialisten som bedriver utbildning i Excel och VBA, tillhandahåller support och hjälp med Excel, utvecklar program i Excel. Är ni i behov av en konsult inom Excel, VBA eller VSTO, eller söker en excelkurs, kontakta oss.
Copyright 2013 ExcelSpecialisten XLS AB   Användarvillkor  Personliga uppgifter