vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Brandneu! sevEingabe v3.0 - Das Eingabecontrol der Superlative!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Fortgeschrittene Programmierung
Re: Excel mit VB 
Autor: RalfH
Datum: 01.04.03 14:38

Servus,

folgender Code bringt Excel wieder in den Vordergrund:
Option Explicit
 
' Fensterhandle ermitteln
Private Declare Function FindWindow Lib "user32" _
        Alias "FindWindowA" (ByVal lpClassName As String, _
        ByVal lpWindowName As String) As Long
 
' Fensterstatus festlegen
Private Declare Function ShowWindow Lib "user32" (ByVal _
        hwnd As Long, ByVal nCmdShow As Long) As Long
 
' Fensterposition festlegen
Private Declare Function SetWindowPos Lib "user32" (ByVal _
        hwnd As Long, ByVal hWndInsertAfter As Long, _
        ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
        ByVal cy As Long, ByVal wFlags As Long) As Long
 
' Fensterposition ermitteln
Private Declare Function GetWindowPlacement Lib "user32" _
        (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As _
        Long
 
Private Type POINTAPI
  x As Long
  y As Long
End Type
 
Private Type RECT
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type
 
Private Type WINDOWPLACEMENT
  Length As Long
  flags As Long
  showCmd As Long
  ptMinPosition As POINTAPI
  ptMaxPosition As POINTAPI
  rcNormalPosition As RECT
End Type
 
Private Const SW_SHOWNOACTIVATE As Long = 4
Private Const SW_SHOWMINIMIZED As Long = 2
 
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const HWND_TOP As Long = 0
 
Public Sub BringExcelToTop()
    Dim WinWnd As Long, Place As WINDOWPLACEMENT
 
    ' Fensterhandle von Excel ermitteln,
    ' WinWnd=0, falls Excel nicht gestartet wurde
    WinWnd = FindWindow("XLMAIN", vbNullString)
 
    ' falls das Fensterhandle von Excel ermittelt
    ' werden konnte, Excel in den Vordergrund bringen
    If WinWnd <> 0 Then
 
      ' Fensterposition von Excel ermitteln
      GetWindowPlacement WinWnd, Place
 
      ' falls Excel minimiert ist,
      ' Fenstergröße wiederherstellen
      If Place.showCmd = SW_SHOWMINIMIZED Then _
        ShowWindow WinWnd, SW_SHOWNOACTIVATE
 
      ' Excel ganz nach oben bringen (Vordergrund),
      ' Position und Größe nicht ändern
      SetWindowPos WinWnd, HWND_TOP, 0, 0, 0, 0, _
        SWP_NOMOVE + SWP_NOSIZE
 
    End If
End Sub

Viel Spass,
R@lf

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Excel mit VB109Lars31.03.03 11:49
Re: Excel mit VB479RalfH31.03.03 15:28
Re: Excel mit VB55Lars31.03.03 16:25
Re: Excel mit VB521RalfH01.04.03 14:38
Re: Excel mit VB48Lars01.04.03 19:19

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel