Clever-Excel-Forum

Normale Version: Userform immer im Vordergrund bei mehreren offenen Arbeitsmappen
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Hallo
 
In Ermangelung einer Lösung für mein Anliegen hier
http://www.clever-excel-forum.de/thread-...l#pid60538
 
habe ich an einer abgespeckten Variante weiter gebastelt.
 
Das Textfeld und die Schaltfläche sind in einer kleinen Userform untergebracht, die im Browserformular nicht stört.

Diese halte ich über

Code in Userform:
Code:
Option Explicit

Private Declare Function SetWindowPos Lib "user32.dll" ( _
   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
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
   ByVal lpClassName As String, _
   ByVal lpWindowName As String) As Long

Private Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const GC_CLASSNAMEUSERFORM = "ThunderDFrame"

Private Sub UserForm_Activate()

   Call SetWindowPos(FindWindow(GC_CLASSNAMEUSERFORM, Caption), _
       HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
       
End Sub

sowie Code in Modul1:
Code:
Sub auto_open()
 
   Application.WindowState = xlMinimized
   AppActivate Application.Caption
   
   UserForm1.Show
   
End Sub

 
Immer im Vordergrund.
Das funktioniert auch soweit es andere Anwendungen betrifft. Allerdings habe ich regelmäßig auch noch andere Excel-Arbeitsmappen geöffnet. An die komme ich nicht mehr heran, solange die Userform im Vordergrund bleibt.  Was muss ich ändern, damit die anderen Arbeitsmappen bearbeitbar bleiben?
 
Und gibt es eine Möglichkeit, solange ich die Arbeitsmappe mit der Userform nutze, die Funktionstaste F7 global für alle anderen Anwendungen mit der Funktion Strg-V zu belegen?

Mit Gruß, Felix
Hallo Felix,

zu Frage 1:

UserForm1.Show 0

Gruß Uwe
Hi auch

Jo das war es. Thx.

Jetzt noch jmd. eiene Idee für die F7?
Hallo,

Zitat:Jetzt noch jmd. eiene Idee für die F7?

meines Wissens ist in Verbindung mit der Nutzung von Userforms
die F7-Taste von Excel bzw. VBA bereits vorbelegt.

Ich persönlich habe das nie benutzt (also Wissen aus einem schlauen Buch).
Hallo Felix,

zu Frage 2:


' **************************************************************
'  Modul:  Modul1  Typ = Allgemeines Modul
' **************************************************************


Option Explicit

Sub auto_open()
  Application.OnKey "{F7}", "prcEinfuegen"
  Application.WindowState = xlMinimized
  AppActivate Application.Caption
  UserForm1.Show
End Sub

Sub auto_close()
 Application.OnKey "{F7}"
End Sub

Sub prcEinfuegen()
 Application.SendKeys "^v"
End Sub

Besser wäre es allerdings, wenn Du auf die aktuelle Variante der Ereignismakros umsteigst:


' **************************************************************
'  Modul:  DieseArbeitsmappe  Typ = Element der Mappe(Sheet, Workbook, ...)
' **************************************************************


Option Explicit

Private Sub Workbook_Open()
  Application.OnKey "{F7}", "prcEinfuegen"
  Application.WindowState = xlMinimized
  AppActivate Application.Caption
  UserForm1.Show
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
 Application.OnKey "{F7}"
End Sub



' **************************************************************
'  Modul:  Modul1  Typ = Allgemeines Modul
' **************************************************************


Option Explicit

Sub prcEinfuegen()
 Application.SendKeys "^v"
End Sub

Code eingefügt mit: Excel Code Jeanie

Gruß Uwe
Hallo,

versuche es mal, denn nur Versuch macht bekanntlich kluch  :05:


der Code gehört in Diese Arbeitsmappe
Zitat:Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnKey "{F7}"
End Sub

Private Sub Workbook_Open()
Application.OnKey "{F7}", "test"       '   > den String anpassen
End Sub
Hola

Es hat leider keine der augelisteten Varianen funktioniert. Im Firefox Browser will bei Benutzung der F7 immer Caret-Browsing gestartet werden und in Word jeweils die Rechtschreibkorrektur.

Wenn ich folgenden Code in Modul 1 ausführe

Code:
Option Explicit

Sub auto_open()
 Application.OnKey "{F7}", "prcEinfuegen"

End Sub

Sub auto_close()
Application.OnKey "{F7}"
End Sub

Sub prcEinfuegen()
Application.SendKeys "^v"
End Sub


funktioniert es nur innerhalb von Excel .


Zitat:Besser wäre es allerdings, wenn Du auf die aktuelle Variante der Ereignismakros umsteigst:


' **************************************************************
'  Modul:  DieseArbeitsmappe  Typ = Element der Mappe(Sheet, Workbook, ...)
' **************************************************************


Option Explicit

Private Sub Workbook_Open()
  Application.OnKey "{F7}", "prcEinfuegen"
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
 Application.OnKey "{F7}"
End Sub



' **************************************************************
'  Modul:  Modul1  Typ = Allgemeines Modul
' **************************************************************


Option Explicit

Sub prcEinfuegen()
 Application.SendKeys "^v"
End Sub

So (minimalisiert) funktioniert es ebenfalls nur innerhalb von Excel.
Hallo Felix,

(11.12.2016, 14:32)felix2000 schrieb: [ -> ]funktioniert es nur innerhalb von Excel .

stimmt, das betrifft nur die Excelanwendung.
Für "global für alle anderen Anwendungen" kann ich leider nicht helfen.

Gruß Uwe