je souhaite afficher une Msgbox sur la partie droite de la=20
fen=EAtre active (feuille de saisie) afin de ne masquer des=20
donn=E9es importantes.
cette msgbox s'affiche par d=E9faut au milieu de la fen=EAtre=20
et je ne trouve pas le moyen en VBA de la d=E9placer.
existe-t-il une solution?
(pack office 97 sr2)
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Laurent
Salut Sébastien,
A ma connaissance, la taille et la position d'une msgbox sont fixes.
Désolé de ne pas pouvoir t'aider plus,
"Sébastien" wrote in message news:043d01c39ee4$fd8304a0$ Bonjour,
je souhaite afficher une Msgbox sur la partie droite de la fenêtre active (feuille de saisie) afin de ne masquer des données importantes. cette msgbox s'affiche par défaut au milieu de la fenêtre et je ne trouve pas le moyen en VBA de la déplacer. existe-t-il une solution? (pack office 97 sr2)
merci pour vos réponses !
Salut Sébastien,
A ma connaissance, la taille et la position d'une msgbox sont fixes.
Désolé de ne pas pouvoir t'aider plus,
L@urent
"Sébastien" <sebasoleines@free.fr> wrote in message
news:043d01c39ee4$fd8304a0$a001280a@phx.gbl...
Bonjour,
je souhaite afficher une Msgbox sur la partie droite de la
fenêtre active (feuille de saisie) afin de ne masquer des
données importantes.
cette msgbox s'affiche par défaut au milieu de la fenêtre
et je ne trouve pas le moyen en VBA de la déplacer.
existe-t-il une solution?
(pack office 97 sr2)
A ma connaissance, la taille et la position d'une msgbox sont fixes.
Désolé de ne pas pouvoir t'aider plus,
"Sébastien" wrote in message news:043d01c39ee4$fd8304a0$ Bonjour,
je souhaite afficher une Msgbox sur la partie droite de la fenêtre active (feuille de saisie) afin de ne masquer des données importantes. cette msgbox s'affiche par défaut au milieu de la fenêtre et je ne trouve pas le moyen en VBA de la déplacer. existe-t-il une solution? (pack office 97 sr2)
merci pour vos réponses !
AV
En bidouillant pour la position :
'Publié par Michel Pierron Private Declare Function UnhookWindowsHookEx Lib "USER32" ( _ ByVal hHook As Long) As Long Private Declare Function GetWindowLong Lib "USER32" Alias _ "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long Private Declare Function SetWindowsHookEx Lib "USER32" Alias _ "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long _ , ByVal hmod As Long, ByVal dwThreadId As Long) 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 Private Declare Function FindWindow Lib "USER32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private lgHook As Long
' On attend l'évènement HCBT_ACTIVATE indiquant l'affichage de la fenêtre Function WinProc(ByVal lMsg As Long, ByVal wParam As Long) As Long If lMsg = 5 Then ' Positionne la fenêtre aux coordonnées (x0, y0) en pixels ' Multiplier par 4/3 pour avoir la correspondance en points SetWindowPos wParam, 0, 600, 100, 0, 0, &H1 Or &H4 Or &H10 ' Rend la main au système UnhookWindowsHookEx lgHook End If WinProc = False End Function
Sub Positionned_MsgBox() Dim lgInst As Long
lgInst = GetWindowLong(FindWindow("XLMAIN", Application.Caption), -6) ' Initialise la fonction de sous-classement lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, lgInst, GetCurrentThreadId) ' Affiche la boîte de message à la position donnée dans WinProc MsgBox "blabla" End Sub
AV
En bidouillant pour la position :
'Publié par Michel Pierron
Private Declare Function UnhookWindowsHookEx Lib "USER32" ( _
ByVal hHook As Long) As Long
Private Declare Function GetWindowLong Lib "USER32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function SetWindowsHookEx Lib "USER32" Alias _
"SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long _
, ByVal hmod As Long, ByVal dwThreadId As Long) 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
Private Declare Function FindWindow Lib "USER32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private lgHook As Long
' On attend l'évènement HCBT_ACTIVATE indiquant l'affichage de la fenêtre
Function WinProc(ByVal lMsg As Long, ByVal wParam As Long) As Long
If lMsg = 5 Then
' Positionne la fenêtre aux coordonnées (x0, y0) en pixels
' Multiplier par 4/3 pour avoir la correspondance en points
SetWindowPos wParam, 0, 600, 100, 0, 0, &H1 Or &H4 Or &H10
' Rend la main au système
UnhookWindowsHookEx lgHook
End If
WinProc = False
End Function
Sub Positionned_MsgBox()
Dim lgInst As Long
lgInst = GetWindowLong(FindWindow("XLMAIN", Application.Caption), -6)
' Initialise la fonction de sous-classement
lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, lgInst, GetCurrentThreadId)
' Affiche la boîte de message à la position donnée dans WinProc
MsgBox "blabla"
End Sub
'Publié par Michel Pierron Private Declare Function UnhookWindowsHookEx Lib "USER32" ( _ ByVal hHook As Long) As Long Private Declare Function GetWindowLong Lib "USER32" Alias _ "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long Private Declare Function SetWindowsHookEx Lib "USER32" Alias _ "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long _ , ByVal hmod As Long, ByVal dwThreadId As Long) 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 Private Declare Function FindWindow Lib "USER32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private lgHook As Long
' On attend l'évènement HCBT_ACTIVATE indiquant l'affichage de la fenêtre Function WinProc(ByVal lMsg As Long, ByVal wParam As Long) As Long If lMsg = 5 Then ' Positionne la fenêtre aux coordonnées (x0, y0) en pixels ' Multiplier par 4/3 pour avoir la correspondance en points SetWindowPos wParam, 0, 600, 100, 0, 0, &H1 Or &H4 Or &H10 ' Rend la main au système UnhookWindowsHookEx lgHook End If WinProc = False End Function
Sub Positionned_MsgBox() Dim lgInst As Long
lgInst = GetWindowLong(FindWindow("XLMAIN", Application.Caption), -6) ' Initialise la fonction de sous-classement lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, lgInst, GetCurrentThreadId) ' Affiche la boîte de message à la position donnée dans WinProc MsgBox "blabla" End Sub
AV
Frédéric Sigonneau
Bonsoir,
Autre solution possible avec un userform créé et détruit à la volée :
'====================== Sub test() MsgBoxPerso "Il pleut", 150, 350 End Sub
Sub MsgBoxPerso(Msg$, Haut&, Gauche&) 'création à la volée d'un userform qui s'affiche avec Msg 'à la position Haut et Gauche Dim UsrForm As Object, lbl As Object
Set UsrForm = ThisWorkbook.VBProject.VBComponents.Add(3) With UsrForm .Properties("Caption") = "Coucou" .Properties("Width") = 200 .Properties("Height") = 100 .Properties("Top") = Haut .Properties("Left") = Gauche .Properties("ShowModal") = True End With
'le texte Set lbl = UsrForm.Designer.Controls.Add("forms.label.1") With lbl .Caption = Msg .Left = 18: .Top = 12: .Width = 165: .Height = 55 .ForeColor = 2036353 'rouge foncé .Font.Bold = True: .Font.Size = 12 End With
'bouton Set Btn = UsrForm.Designer.Controls.Add("forms.commandbutton.1") With Btn .Caption = "OK" .Height = 25 .Left = 60: .Top = 45 End With With UsrForm.CodeModule X = .CountOfLines .insertlines X + 1, "Sub CommandButton1_Click()" .insertlines X + 2, " Me.Hide" .insertlines X + 3, "End Sub" End With
VBA.UserForms.Add(UsrForm.Name).Show
ThisWorkbook.VBProject.VBComponents.Remove UsrForm End Sub '====================== FS -- Frédéric Sigonneau [MVP Excel - né un sans-culottide] Gestions de temps, VBA pour Excel : http://perso.wanadoo.fr/frederic.sigonneau Si votre question sur Excel est urgente, évitez ma bal !
Bonjour,
je souhaite afficher une Msgbox sur la partie droite de la fenêtre active (feuille de saisie) afin de ne masquer des données importantes. cette msgbox s'affiche par défaut au milieu de la fenêtre et je ne trouve pas le moyen en VBA de la déplacer. existe-t-il une solution? (pack office 97 sr2)
merci pour vos réponses !
Bonsoir,
Autre solution possible avec un userform créé et détruit à la volée :
'====================== Sub test()
MsgBoxPerso "Il pleut", 150, 350
End Sub
Sub MsgBoxPerso(Msg$, Haut&, Gauche&)
'création à la volée d'un userform qui s'affiche avec Msg
'à la position Haut et Gauche
Dim UsrForm As Object, lbl As Object
Set UsrForm = ThisWorkbook.VBProject.VBComponents.Add(3)
With UsrForm
.Properties("Caption") = "Coucou"
.Properties("Width") = 200
.Properties("Height") = 100
.Properties("Top") = Haut
.Properties("Left") = Gauche
.Properties("ShowModal") = True
End With
'le texte
Set lbl = UsrForm.Designer.Controls.Add("forms.label.1")
With lbl
.Caption = Msg
.Left = 18: .Top = 12: .Width = 165: .Height = 55
.ForeColor = 2036353 'rouge foncé
.Font.Bold = True: .Font.Size = 12
End With
'bouton
Set Btn = UsrForm.Designer.Controls.Add("forms.commandbutton.1")
With Btn
.Caption = "OK"
.Height = 25
.Left = 60: .Top = 45
End With
With UsrForm.CodeModule
X = .CountOfLines
.insertlines X + 1, "Sub CommandButton1_Click()"
.insertlines X + 2, " Me.Hide"
.insertlines X + 3, "End Sub"
End With
VBA.UserForms.Add(UsrForm.Name).Show
ThisWorkbook.VBProject.VBComponents.Remove UsrForm
End Sub
'======================
FS
--
Frédéric Sigonneau [MVP Excel - né un sans-culottide]
Gestions de temps, VBA pour Excel :
http://perso.wanadoo.fr/frederic.sigonneau
Si votre question sur Excel est urgente, évitez ma bal !
Bonjour,
je souhaite afficher une Msgbox sur la partie droite de la
fenêtre active (feuille de saisie) afin de ne masquer des
données importantes.
cette msgbox s'affiche par défaut au milieu de la fenêtre
et je ne trouve pas le moyen en VBA de la déplacer.
existe-t-il une solution?
(pack office 97 sr2)
Autre solution possible avec un userform créé et détruit à la volée :
'====================== Sub test() MsgBoxPerso "Il pleut", 150, 350 End Sub
Sub MsgBoxPerso(Msg$, Haut&, Gauche&) 'création à la volée d'un userform qui s'affiche avec Msg 'à la position Haut et Gauche Dim UsrForm As Object, lbl As Object
Set UsrForm = ThisWorkbook.VBProject.VBComponents.Add(3) With UsrForm .Properties("Caption") = "Coucou" .Properties("Width") = 200 .Properties("Height") = 100 .Properties("Top") = Haut .Properties("Left") = Gauche .Properties("ShowModal") = True End With
'le texte Set lbl = UsrForm.Designer.Controls.Add("forms.label.1") With lbl .Caption = Msg .Left = 18: .Top = 12: .Width = 165: .Height = 55 .ForeColor = 2036353 'rouge foncé .Font.Bold = True: .Font.Size = 12 End With
'bouton Set Btn = UsrForm.Designer.Controls.Add("forms.commandbutton.1") With Btn .Caption = "OK" .Height = 25 .Left = 60: .Top = 45 End With With UsrForm.CodeModule X = .CountOfLines .insertlines X + 1, "Sub CommandButton1_Click()" .insertlines X + 2, " Me.Hide" .insertlines X + 3, "End Sub" End With
VBA.UserForms.Add(UsrForm.Name).Show
ThisWorkbook.VBProject.VBComponents.Remove UsrForm End Sub '====================== FS -- Frédéric Sigonneau [MVP Excel - né un sans-culottide] Gestions de temps, VBA pour Excel : http://perso.wanadoo.fr/frederic.sigonneau Si votre question sur Excel est urgente, évitez ma bal !
Bonjour,
je souhaite afficher une Msgbox sur la partie droite de la fenêtre active (feuille de saisie) afin de ne masquer des données importantes. cette msgbox s'affiche par défaut au milieu de la fenêtre et je ne trouve pas le moyen en VBA de la déplacer. existe-t-il une solution? (pack office 97 sr2)