Prikazi cijelu temu 28.12.2024 23:59
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Lokacija:Tuzla


Predmet:Re:Nakon klika na excel file minimizirat i pokaze samo userform1
Ovaj kod stavi u neki modul. Otvori novi modul ako nemas.
PreuzmiIzvorni kôd (Visual Basic):
  1. #If VBA7 Then
  2.     Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  3.     Private Declare PtrSafe Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
  4.     Private Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
  5.     Private Declare PtrSafe Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, ByRef lpdwProcessId As Long) As Long
  6.     Private Declare PtrSafe Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
  7. #Else
  8.     Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  9.     Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
  10.     Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
  11.     Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, ByRef lpdwProcessId As Long) As Long
  12.     Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
  13. #End If
  14.  
  15. Const SW_MINIMIZE = 6
  16.  
  17.  
  18. Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
  19.     Dim windowTitle As String
  20.     Dim processId As Long
  21.    
  22.     If IsWindowVisible(hwnd) Then
  23.         windowTitle = String$(256, Chr$(0))
  24.         GetWindowText hwnd, windowTitle, Len(windowTitle)
  25.         windowTitle = Left$(windowTitle, InStr(windowTitle, Chr$(0)) - 1)
  26.         If Len(windowTitle) > 0 Then
  27.             br = InStr(1, windowTitle, "Microsoft Visual Basic for Applications")
  28.             If br > 0 Then
  29.             ShowWindow hwnd, SW_MINIMIZE
  30.             Exit Function
  31.             End If
  32.         End If
  33.     End If
  34.     EnumWindowsProc = 1
  35. End Function
  36.  
  37. Function Minimiziraj()
  38.     EnumWindows AddressOf EnumWindowsProc, 0
  39. End Function
a ovo stavi u modul user form
PreuzmiIzvorni kôd (Visual Basic):
  1. Private Sub UserForm_Initialize()
  2.    Minimiziraj
  3. End Sub

Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.