Ich hab mir jetzt ein VB Code geholt der funktioniert aber nur in Excel wenn ich in Visual Studio .Net diesen Compiliere geht da nix hat jemand ne Idee.
Hier der Quelltext:
Public Class Form1
' Steuerelement: Schaltfläche "Command2"
' Steuerelement: Schaltfläche "Command1"
Inherits System.Windows.Forms.Form
'Deklaration: Globale Form API-Konstanten
Private Const SWP_HIDEWINDOW As Long = &H80&
Private Const SWP_SHOWWINDOW As Long = &H40&
'Deklaration: Globale Form API-Funktionnen
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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
#Region " Vom Windows Form Designer generierter Code "
Public Sub New()
MyBase.New()
' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
InitializeComponent()
' Initialisierungen nach dem Aufruf InitializeComponent() hinzufügen
End Sub
' Die Form überschreibt den Löschvorgang der Basisklasse, um Komponenten zu bereinigen.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
' Für Windows Form-Designer erforderlich
Private components As System.ComponentModel.IContainer
'HINWEIS: Die folgende Prozedur ist für den Windows Form-Designer erforderlich
'Sie kann mit dem Windows Form-Designer modifiziert werden.
'Verwenden Sie nicht den Code-Editor zur Bearbeitung.
Friend WithEvents Command1 As System.Windows.Forms.Button
Friend WithEvents Command2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Command1 = New System.Windows.Forms.Button
Me.Command2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Command1
'
Me.Command1.Location = New System.Drawing.Point(88, 72)
Me.Command1.Name = "Command1"
Me.Command1.Size = New System.Drawing.Size(104, 40)
Me.Command1.TabIndex = 0
Me.Command1.Text = "Button1"
'
'Command2
'
Me.Command2.Location = New System.Drawing.Point(88, 128)
Me.Command2.Name = "Command2"
Me.Command2.Size = New System.Drawing.Size(104, 40)
Me.Command2.TabIndex = 1
Me.Command2.Text = "Button2"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Command2)
Me.Controls.Add(Me.Command1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
'Deklaration: Lokale Prozedur-Variablen
Dim lngResult As Long
'Ausblenden
'lngResult = FindWindow("Shell_TrayWnd", vbNullString)
lngResult = 65624
SetWindowPos(lngResult, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)
End Sub
Private Sub Command2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command2.Click
'Deklaration: Lokale Prozedur-Variablen
Dim lngResult As Long
'Einblenden
'lngResult = FindWindow("Shell_TrayWnd", vbNullString)
lngResult = 65624
SetWindowPos(lngResult, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
End Sub
End Class