Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1796to1800
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
Inhaltsverzeichnis

Application.Visible = False + Tasksymbol

Application.Visible = False + Tasksymbol
10.12.2020 10:00:30
M.A.
Hallo zusammen,
ich verzweifle, auch nach intensiver Recherche an einem Problem.
Mit Application.Visible = False und UserForm1.Show wird nur noch die Userform angezeigt, jedoch in der Taskleiste ausgeblendet.
Falls die Userform jedoch durch andere Programme überlagert wird (Browser etc.), muss man erst alles wieder minimieren, damit man zur Userform gelangt. (Der Mitarbeiter hat durchaus mehrere Excel Dateien offen / Meine Datei wird bereits als neue Applikation geöffnet).
Habe von Lösungen gehört mit

Application.OnKey "Taste", "Makro" 
oder mit

API Funktionen
(die denke ich auf meiner Arbeit nicht funktionieren) von Nepumuk oder auf folgende Variante:
1. Als Add-In speichern
2. in "DieseArbeitsmappe":
Private Sub Workbook_Open()
Application.Visible = False
UserForm1.Show
Application.Quit
End Sub
und dann, drittens, im Modul des UserForms:
Private Sub UserForm_Initialize()
Application.WindowState = xlMinimized
Application.Visible = True
End Sub

Alles bekomme ich nicht wie gewünscht zum Laufen. (Noch nie mit Makros als Addins gearbeitet.)
Es kann auch ruhig das normale Excel Symbol in der Taskleiste angezeigt werden.
Ich hoffe es weis jemand Rat.
Vielen Dank vorab und liebe Grüße
M.A.

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Application.Visible = False + Tasksymbol
10.12.2020 10:32:46
Nepumuk
Hallo,
teste mal:
Option Explicit

#If Win64 Then
Private Declare PtrSafe Function GetWindowLongPtr Lib "user32.dll" Alias "GetWindowLongPtrA" ( _
    ByVal Hwnd As LongPtr, _
    ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongPtr Lib "user32.dll" Alias "SetWindowLongPtrA" ( _
    ByVal Hwnd As LongPtr, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As LongPtr) As LongPtr
#Else
Private Declare PtrSafe Function GetWindowLongPtr Lib "user32.dll" Alias "GetWindowLongA" ( _
    ByVal Hwnd As LongPtr, _
    ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongPtr Lib "user32.dll" Alias "SetWindowLongA" ( _
    ByVal Hwnd As LongPtr, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As LongPtr) As LongPtr
#End If

Private Declare PtrSafe Function FindWindowA Lib "user32.dll" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function ShowWindow Lib "user32.dll" ( _
    ByVal Hwnd As LongPtr, _
    ByVal nCmdShow As Long) As Long
Private Declare PtrSafe Function SendMessageA Lib "user32.dll" ( _
    ByVal Hwnd As LongPtr, _
    ByVal wMsg As Long, _
    ByVal wParam As LongPtr, _
    ByVal lParam As Any) As LongPtr

Private Const WM_SETICON As Long = &H80
Private Const GC_CLASSNAMEUSERFORM As String = "ThunderDFrame"
Private Const GWL_EXSTYLE As Long = -20
Private Const WS_EX_APPWINDOW As LongPtr = &H40000
Private Const SW_HIDE As Long = 0
Private Const SW_SHOW As Long = 5

Private mlngptrHwnd As LongPtr

Private Sub CommandButton1_Click()
    Call Unload(Object:=Me)
    ' Application.Visible = True
End Sub

Private Sub UserForm_Activate()
    Dim lngptrStyle As LongPtr
    Call ShowWindow(Hwnd, SW_HIDE)
    lngptrStyle = GetWindowLongPtr(Hwnd, GWL_EXSTYLE)
    lngptrStyle = lngptrStyle Or WS_EX_APPWINDOW
    Call SetWindowLongPtr(Hwnd, GWL_EXSTYLE, lngptrStyle)
    Call ShowWindow(Hwnd, SW_SHOW)
End Sub

Private Sub UserForm_Initialize()
    Hwnd = FindWindowA(GC_CLASSNAMEUSERFORM, Caption)
    'Icon in Titlebar and Taskbarwindow
    ' Call SendMessageA(Hwnd, WM_SETICON, 0&, Image1.Picture.Handle)
End Sub

Private Property Get Hwnd() As LongPtr
    Hwnd = mlngptrHwnd
End Property

Private Property Let Hwnd(ByVal pvlngptrHwnd As LongPtr)
    mlngptrHwnd = pvlngptrHwnd
End Property

Gruß
Nepumuk
Anzeige
AW: Application.Visible = False + Tasksymbol
10.12.2020 10:53:04
Nepumuk
Ooooooooooops,
vor 2013 !!! Dafür habe ich keine Lösung.
Gruß
Nepumuk
AW: Application.Visible = False + Tasksymbol
11.12.2020 11:20:34
M.A.
Ok, dennoch danke für den Versuch :)
Schauen wir mal weiter.
Lg.
AW: Application.Visible = False + Tasksymbol
11.12.2020 11:20:34
M.A.
Ok, dennoch danke für den Versuch :)
Schauen wir mal weiter.
Lg.

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige