Se connecter avec
S'enregistrer | Connectez-vous

[vb]minimiser une userform sur excel

Dernière réponse : dans Programmation

slt
j'ai vu ca dans un forum (pour minimiser une userform dans la barre des taches)et je sais pas du tout comment il faut le placer dans le code de ma userform :

Salut,

Colles ceci dans le module de ton USF, cela te rajoutera un bouton de réduction:
  1. '<a href="http://www.allapi.com" target="_blank">www.allapi.com</a>
  2. Private Declare Function FindWindowA& Lib "User32" (ByVal lpClassName$, ByVal lpWindowName$)
  3. Private Declare Function EnableWindow& Lib "User32" (ByVal hWnd&, ByVal bEnable&)
  4. Private Declare Function GetWindowLongA& Lib "User32" (ByVal hWnd&, ByVal nIndex&)
  5. Private Declare Function SetWindowLongA& Lib "User32" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
  6.  
  7. Private Sub UserForm_Activate()
  8. EnableWindow FindWindowA("XLMAIN", Application.Caption), 1
  9. End Sub
  10.  
  11. Private Sub UserForm_Initialize()
  12. Dim hWnd As Long
  13. hWnd = FindWindowA(vbNullString, Me.Caption)
  14. SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) Or &H20000
  15. End Sub

quelqu'un peut-il maider

Autres pages sur : minimiser userform excel

Lassé par la pub ? Créez un compte

Ca marche mais maintenant j'ai une erreur :
erreur d'execution 70
accés refusé
qu'est ce que c'est cette erreur
voila mon code :
  1. Private Declare Function FindWindowA& Lib "User32" (ByVal lpClassName$, ByVal lpWindowName$)
  2. Private Declare Function EnableWindow& Lib "User32" (ByVal hWnd&, ByVal bEnable&)
  3. Private Declare Function GetWindowLongA& Lib "User32" (ByVal hWnd&, ByVal nIndex&)
  4. Private Declare Function SetWindowLongA& Lib "User32" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
  5.  
  6.  
  7. Private Sub Ajouter_Click()
  8.  
  9. Dim Cel As Range
  10. Dim Cel2 As Range
  11. Dim Cel3 As Range
  12.  
  13. If Range("A2") = "" Then
  14.  
  15. Set Cel = Range("A2")
  16. Set Cel2 = Range("A2").Offset(0, 1)
  17. Set Cel3 = Range("A2").Offset(0, 2)
  18.  
  19. Else
  20.  
  21. Set Cel = Range("A1").End(xlDown).Offset(1, 0)
  22. Set Cel2 = Range("A1").End(xlDown).Offset(1, 1)
  23. Set Cel3 = Range("A1").End(xlDown).Offset(1, 2)
  24.  
  25. End If
  26.  
  27. Cel = TextBoxNom
  28. Cel2 = TextBoxNum
  29. Cel3 = ComboBoxServ
  30.  
  31. End Sub
  32.  
  33. Private Sub CommandButton1_Click()
  34.  
  35. Worksheets("A-F").Select
  36.  
  37. End Sub
  38.  
  39. Private Sub CommandButton2_Click()
  40.  
  41. Worksheets("G-M").Select
  42.  
  43. End Sub
  44.  
  45. Private Sub CommandButton3_Click()
  46.  
  47. Worksheets("N-S").Select
  48.  
  49. End Sub
  50.  
  51. Private Sub CommandButton4_Click()
  52.  
  53. Worksheets("T-Z").Select
  54.  
  55. End Sub
  56.  
  57.  
  58. Private Sub UserForm_Initialize()
  59.  
  60. Dim Lrange As Range
  61. Dim Lrange2 As Range
  62. Dim x As Variant
  63. Dim y As Variant
  64.  
  65. ' Set the range to loop through.
  66. Set Lrange = Range("J2:J3")
  67. Set Lrange2 = Range("A1:C1")
  68. ' Loops through the ranges.
  69.  
  70. For Each x In Lrange
  71.  
  72. ' Adds an item to the list.
  73. ComboBoxService.AddItem x.Value
  74. ComboBoxServ.AddItem x.Value
  75.  
  76. Next x
  77.  
  78. For Each y In Lrange2
  79.  
  80. ListBoxListeRep.AddItem y.Value
  81.  
  82. Next y
  83.  
  84.  
  85. Dim hWnd As Long
  86. hWnd = FindWindowA(vbNullString, Me.Caption)
  87. SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) Or &H20000
  88.  
  89. End Sub
  90.  
  91. Private Sub UserForm_Activate()
  92.  
  93. EnableWindow FindWindowA("XLMAIN", Application.Caption), 1
  94.  
  95. End Sub
Lassé par la pub ? Créez un compte