Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
MsgBox "Bitte mit dem Button 'Ende' schließen!"
Cancel = True
End If
End Sub das Schließen mit dem Kreuzle verhindert. Habe eine Public Variable (boolean) namens bolSchliessen und einen Ende Button Private Sub cboEnde_Click()
Application.DisplayAlerts = False 'Warnmeldung ausschalten
Unload frmStart
bolSchliessen = True
Application.Quit
End Sub Klappt alles wunderbar, nur Excel ist noch auf und soll natürlich auch nicht mit dem Kreuzle geschlossen werden und keinesfalls gespeichert werden beim Schließen. Also hab ich in "diese Arbeitsmappe" den Code Private Sub Workbook_BeforeClose(Cancel As Boolean)
If bolSchliessen = False Then
MsgBox "Bitte mit dem Button 'Programm beenden' schließen!"
Cancel = True
End If
End Sub und dort auch einen Programm beenden Button mit dem Code: Private Sub BtnBeenden_Click()
Application.DisplayAlerts = False 'Warnmeldung ausschalten
bolSchliessen = True
Application.Quit
End Sub
[b]xlWB.Close SaveChanges:=False
xlAppl.Application.Quit[/b][b]Option Explicit
Option Base 1
Option Private Module
Public Const GWL_STYLE = (-16)
Public Const WS_SYSMENU = &H80000
Public newClas As New clsApp_1
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
'####################################################################################################################
Public Sub Schließenkreuz_einblenden()
Dim xl_hwnd, lStyle
xl_hwnd = FindWindow("xlMain", vbNullString)
If xl_hwnd <> 0 Then
lStyle = GetWindowLong(xl_hwnd, GWL_STYLE)
lStyle = SetWindowLong(xl_hwnd, GWL_STYLE, lStyle Or WS_SYSMENU)
DrawMenuBar xl_hwnd
End If
End Sub
'####################################################################################################################
Public Sub Schließenkreuz_ausblenden()
Dim xl_hwnd, lStyle
xl_hwnd = FindWindow("xlMain", vbNullString)
If xl_hwnd <> 0 Then
lStyle = GetWindowLong(xl_hwnd, GWL_STYLE)
lStyle = SetWindowLong(xl_hwnd, GWL_STYLE, lStyle And Not WS_SYSMENU)
DrawMenuBar xl_hwnd
End If
End Sub
'####################################################################################################################
Sub procControlEnableDisable(intId As Integer, _
bolStatus As Boolean)
Dim cmbSuche As CommandBar
Dim cmbcSteuerelement As CommandBarControl
For Each cmbSuche In Application.CommandBars
Set cmbcSteuerelement = _
cmbSuche.FindControl(ID:=intId, recursive:=True)
If Not cmbcSteuerelement Is Nothing Then
cmbcSteuerelement.Enabled = bolStatus
End If
Next
End Sub[/b][b]Option Explicit
Public WithEvents App As Application
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
Dim myApplication As Object, strWorkbooksNamePfad
If Wb.FullName <> ThisWorkbook.FullName Then
Set myApplication = New Excel.Application
strWorkbooksNamePfad = Wb.FullName
Workbooks(Wb.Name).Close False
myApplication.Workbooks.Open (strWorkbooksNamePfad)
myApplication.Visible = True
Set myApplication = Nothing
End If
End Sub[/b][b]Public newClas As New clsApp_1[/b][b]Option Explicit
Dim Reg As New IWshShell_Class
Sub Schreiben()
Reg.RegWrite "HKCU\Software\IMF\Programm\No.1", Dein Variablenwert
End Sub[/b][b]Option Explicit
Dim Reg As New IWshShell_Class
Sub Lesen()
Variable_Excel = Reg.RegRead("HKCU\Software\IMF\Programm\No.1")
End Sub[/b][b]Me.CboKunden.Text = ""[/b][b]Private Sub ComboBox1_Change()
If ComboBox1.Text <> "" Then
'Hier dann Dein weiterer Code
End If
End Sub[/b][b]Public Sperre As Boolean
Private Sub CommandButton1_Click()
Sperre = True
ComboBox1.Text = ""
Sperre = False
End Sub
Private Sub ComboBox1_Change()
If Sperre = False Then
'Hier dann Dein weiterer Code
End If
End Sub
[/b]Private Sub ComboBox1_Change()
If ComboBox1.Text <> "" Then
'Hier dann Dein weiterer Code
End If
End Sub[b]Application.CommandBars("Worksheet Menu Bar").Enabled = False[/b][b]Dim Menue As CommandBar
On Error Resume Next
For Each Menue In Application.CommandBars
Menue.Enabled = False
Next
On Error GoTo 0[/b]Sperre = True
blabla
Sperre = False
[b]Range("A1") = ExecuteExcel4Macro("'C:\[Dateiname.xls]Blattname'!R1C1")[/b]Private Sub CommandButton1_Click()
If Application.CommandBars("Worksheet Menu Bar").Enabled = True Then
Application.CommandBars("Worksheet Menu Bar").Enabled = False
Else
Application.CommandBars("Worksheet Menu Bar").Enabled = True
End If
End Sub
"Hyperlink einfügen"-Funktion im UserForm nutzen
Cuidas 26.02.2007 - 172 Hits -
Excel benutzen, trotz offener Userform
BlauLED 22.10.2007 - 162 Hits - 1 Antwort
Beim Start einer Exceldatei, automatisch eine Userform öffnet und Excel verschwindet im Hintergrund
Mr.X 16.02.2008 - 67 Hits - 2 Antworten
Globale Variable im Formular Anzeigen
AndiS 28.02.2008 - 109 Hits -
VB6 Variable in anderen Sub übergeben
da_horscht 28.11.2009 - 100 Hits - 6 Antworten