ThisWorkbook.close funkt nicht... Was für Profis!
04.03.2004 15:28:15
Joey
Bitte um Hilfe! Ich möchte dass nur dieses Workbook geschlossen wird, dass diesen Code enthält. Sollte im Hintergrund ein anderes Workbook offen sein, soll dieses nicht geschlossen werden. Zuerst der Code der das Programm schliessen soll, anschliessend der Code Before_Close. Bitte um Hilfe, ist sehr wichtig, danke!
Private Sub CommandButton1_Click()
Unload Frage_speichern
Dim oBar As CommandBar
Dim iRow As Integer
On Error Resume Next
iRow = 1
With ThisWorkbook.Worksheets("CmdBars")
Do Until IsEmpty(.Cells(iRow, 1))
Application.CommandBars(.Cells(iRow, 1).Value).Visible = True
iRow = iRow + 1
Loop
.Cells.ClearContents
End With
Range("AV4").Select
ActiveCell.FormulaR1C1 = "1"
Application.CommandBars("WorksheetMenuBar").Enabled = True
Application.DisplayFormulaBar = True
Application.DisplayAlerts = False
If Workbooks.Count = 1 Then
Application.Quit
Else
ThisWorkbook.Close True
End If
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Worksheets("Hauptseite") _
.cmdSchliessen.PrintObject = True Then
Cancel = True
Exit Sub
End If
Call AusEinSchalten(True)
Dim oBar As CommandBar
Dim iRow As Integer
On Error Resume Next
iRow = 1
With ThisWorkbook.Worksheets("CmdBars")
Do Until IsEmpty(.Cells(iRow, 1))
Application.CommandBars(.Cells(iRow, 1).Value).Visible = True
iRow = iRow + 1
Loop
.Cells.ClearContents
End With
Application.CommandBars("Worksheet Menu Bar").Enabled = True
Application.DisplayFormulaBar = True
On Error GoTo 0
End Sub