Frage zum Makro um Schließenkreuz auszublenden?
22.09.2006 11:49:17
Kasimir
Ich bräuchte mal wieder Eure Hilfe. Ich habe in der Recherche einen Code gefunden, mit dem ich Schaltflächen Minimieren, Wiederherstellen und Schließen in der Titelleiste ausblende. Nun ist es so, dass dort auch das Excelicon in der Titelleiste, das links von dem Schriftzug Microsoft Excel Datename.xls angezeigt wird, ebenfalls ausgeblendet wird. Aufgrund meiner dann doch bescheidenen VBA- Kenntnisse, stehe ich auf dem Schlauch, welchen Befehl ich anpassen muss, damit das Excelsymbol angezeigt wird. Nachfolgend die Makros, die im Modul stehen:
Option Explicit
Option Base 1
Option Private Module
Public Const GWL_STYLE = (-16)
Public Const WS_SYSMENU = &H80000
Public newClas As New clsApp
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ßen_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ßen_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
Dann gehört noch der nachfolgende Code dazu, der im Klassenmodul steht:
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
Ich hoffe, jemand ist dann doch etwas fitter auf dem Gebiet als ich und kann mir einen Tipp geben, wie ich die 3 Schaltflächen (Minimieren, Wiederherstellen und Schließen) ausblende, das Excelsymbol aber sichtbar bleibt.
Danke Euch und Gruß,
Kasimir