Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
508to512
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
508to512
508to512
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Excel Symbol ändern

Excel Symbol ändern
31.10.2004 21:47:31
Tobias
Hallo zusammen!
Ich würde gerne das Excel Symbol oben links gegen ein eigenes tauschen (geht das mit einem ähnlichen Befehl wie Application.Caption=XXX ?)
Ich hab im Internet auch schon einen Code gefunden der dies angeblich bewerkstelligen soll. Aber bei mir geht das nicht (ich hab ihn in die Workbook_open Prozedur gesteckt. Vielleicht war das der Fehler.
Vielleicht kann mir jemand weiterhelfen, indem er mir ein paar Tipps und Erläuterungen zu diesem Code gibt oder nicht besser: mir einen einfacheren sagen kann.
Auf jeden Fall schon mal vielen Dank und viele Grüße
Tobias
Hier noch der Code, den ich gefunden hatte:
***************************************************************************
Das Excelsymbol in der Titelleiste durch ein eigenes Icon ersetzen.
'(Code starten mit '

Sub FensterSymbolÄndern ()') Declare 

Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare 

Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Declare 

Function ExtractIcon Lib "shell32.dll" _
Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, _
ByVal nIconIndex As Long) As Long
Declare 

Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, _
ByVal lparam As Long) As Long
Const WM_SETICON As Long = &H80
Public 

Function fncSetXLWindowIcon(Optional IconFile As String = vbNullString, _
Optional WorkbookName As String = vbNullString) As Boolean
Dim XLMAINhWnd As Long, XLDESKhWnd As Long, _
EXCEL7hWnd As Long, TargetWindowhWnd As Long, _
VirtualIcon As Long
fncSetXLWindowIcon = True
On Error Resume Next
If CBool(Len((Workbooks(WorkbookName).Name))) Then
WorkbookName = Workbooks(WorkbookName).Windows(1).Caption
End If
On Error GoTo ExitFunction
If Not WorkbookName = vbNullString Then
XLMAINhWnd = FindWindow("XLMAIN", Application.Caption)
XLDESKhWnd = FindWindowEx(XLMAINhWnd, 0, "XLDESK", vbNullString)
TargetWindowhWnd = FindWindowEx(XLDESKhWnd, 0, "EXCEL7", WorkbookName)
Else
XLMAINhWnd = FindWindow("XLMAIN", Application.Caption)
TargetWindowhWnd = XLMAINhWnd
End If
If TargetWindowhWnd = 0 Then Exit Function
If IconFile = vbNullString Then
VirtualIcon = 0
Else
VirtualIcon = ExtractIcon(0, IconFile, 0)
If VirtualIcon <= 1 Then Exit Function
End If
SendMessage TargetWindowhWnd, WM_SETICON, True, VirtualIcon
SendMessage TargetWindowhWnd, WM_SETICON, False, VirtualIcon
fncSetXLWindowIcon = True
ExitFunction:
End Function


Sub FensterSymbolÄndern_fncSetXLWindowIcon()
'Fenstericon setzen
fncSetXLWindowIcon ("C:\DeinIcon.ico") '<-- Anpassen!!
End Sub


Sub FensterSymbolOriginal_fncSetXLWindowIcon()
'Fenstericon löschen
fncSetXLWindowIcon
End 

Sub

		

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Excel Symbol ändern
02.11.2004 03:18:05
Uwe
Hallo Tobias,
da hast Du einiges durcheinandergewürfelt. So funktioniert es:
Option Explicit
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Declare Function ExtractIcon Lib "shell32.dll" _
Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, _
ByVal nIconIndex As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, _
ByVal lparam As Long) As Long
Const WM_SETICON As Long = &H80
Public Function fncSetXLWindowIcon(Optional IconFile As String = vbNullString, _
Optional WorkbookName As String = vbNullString) As Boolean
Dim XLMAINhWnd As Long, XLDESKhWnd As Long, _
EXCEL7hWnd As Long, TargetWindowhWnd As Long, _
VirtualIcon As Long
fncSetXLWindowIcon = True
On Error Resume Next
If CBool(Len((Workbooks(WorkbookName).Name))) Then
WorkbookName = Workbooks(WorkbookName).Windows(1).Caption
End If
On Error GoTo ExitFunction
If Not WorkbookName = vbNullString Then
XLMAINhWnd = FindWindow("XLMAIN", Application.Caption)
XLDESKhWnd = FindWindowEx(XLMAINhWnd, 0, "XLDESK", vbNullString)
TargetWindowhWnd = FindWindowEx(XLDESKhWnd, 0, "EXCEL7", WorkbookName)
Else
XLMAINhWnd = FindWindow("XLMAIN", Application.Caption)
TargetWindowhWnd = XLMAINhWnd
End If
If TargetWindowhWnd = 0 Then Exit Function
If IconFile = vbNullString Then
VirtualIcon = 0
Else
VirtualIcon = ExtractIcon(0, IconFile, 0)
If VirtualIcon <= 1 Then Exit Function
End If
SendMessage TargetWindowhWnd, WM_SETICON, True, VirtualIcon
SendMessage TargetWindowhWnd, WM_SETICON, False, VirtualIcon
fncSetXLWindowIcon = True
ExitFunction:
End Function
Sub FensterSymbolÄndern_fncSetXLWindowIcon()
'Fenstericon setzen
fncSetXLWindowIcon ("C:\DeinIcon.ico") '<-- Anpassen!!
End Sub
Sub FensterSymbolOriginal_fncSetXLWindowIcon()
'Fenstericon löschen
fncSetXLWindowIcon
End Sub

Gruß Uwe
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige