OVH Cloud OVH Cloud

Ouvrir une page web

5 réponses
Avatar
Sébastien
Bonjour,

Ma question a déjà été posée de nombreuses fois mais je ne parvient pas à
retrouver la réponse.
Comment ouvre-t-on une page web via un bouton ? (www.google.fr)

Un truc avec shell ? non ? je ne sais plus.
Merci de votre aide.

Sébastien

5 réponses

Avatar
Guy
Salut,

voici une façon (pas la plus simple) via API:

'DANS UN MODULE
Private Declare Function ShellExecute Lib "shell32" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3

Public Sub RunShellExecute(sTopic As String, sFile As
Variant, _
sParams As Variant, sDirectory
As Variant, _
nShowCmd As Long)

Dim RetVal As Long
'execute the passed operation, passing
'the desktop as the window to receive
'any error messages
RetVal = ShellExecute(GetDesktopWindow(), _
sTopic, _
sFile, _
sParams, _
sDirectory, _
nShowCmd)

Call ShowWindow(RetVal, SW_SHOWNORMAL)
End Sub


-> Commande pour ouvrir une page WEB:
Call RunShellExecute("open", "http://www.google.fr", 0&,
0&, SW_SHOWNORMAL)

Tchao

Guy

-----Message d'origine-----
Bonjour,

Ma question a déjà été posée de nombreuses fois mais je


ne parvient pas à
retrouver la réponse.
Comment ouvre-t-on une page web via un bouton ?


(www.google.fr)

Un truc avec shell ? non ? je ne sais plus.
Merci de votre aide.

Sébastien


.



Avatar
Sébastien
Erreur:
"GetDesktopWindow()"
---> fonction non définie


"Guy" a écrit dans le message de
news:061801c3930e$bc056040$
Salut,

voici une façon (pas la plus simple) via API:

'DANS UN MODULE
Private Declare Function ShellExecute Lib "shell32" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3

Public Sub RunShellExecute(sTopic As String, sFile As
Variant, _
sParams As Variant, sDirectory
As Variant, _
nShowCmd As Long)

Dim RetVal As Long
'execute the passed operation, passing
'the desktop as the window to receive
'any error messages
RetVal = ShellExecute(GetDesktopWindow(), _
sTopic, _
sFile, _
sParams, _
sDirectory, _
nShowCmd)

Call ShowWindow(RetVal, SW_SHOWNORMAL)
End Sub


-> Commande pour ouvrir une page WEB:
Call RunShellExecute("open", "http://www.google.fr", 0&,
0&, SW_SHOWNORMAL)

Tchao

Guy

-----Message d'origine-----
Bonjour,

Ma question a déjà été posée de nombreuses fois mais je


ne parvient pas à
retrouver la réponse.
Comment ouvre-t-on une page web via un bouton ?


(www.google.fr)

Un truc avec shell ? non ? je ne sais plus.
Merci de votre aide.

Sébastien


.



Avatar
BossHog
Salut,
en fait voila le code que je me suis permis de corriger:
'***************************************************************************
************
'Dans un FORM
'***************************************************************************
************
Private Sub Command1_Click()
RunShellExecute "open", "http://www.google.fr", 0&, 0&, SW_SHOWNORMAL
End Sub



'***************************************************************************
************
'DANS UN MODULE

'***************************************************************************
************
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal
nCmdShow As Long) As Long
Private Declare Function ShellExecute Lib "shell32" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3

Public Sub RunShellExecute(sTopic As String, sFile As Variant, sParams As
Variant, sDirectory As Variant, nShowCmd As Long)

Dim RetVal As Long
'execute the passed operation, passing
'the desktop as the window to receive
'any error messages
RetVal = ShellExecute(GetDesktopWindow, sTopic, sFile, sParams,
sDirectory, nShowCmd)

ShowWindow RetVal, SW_SHOWNORMAL
End Sub

L'idéal serai d'avoir la solution pour avoir accès au contenu de la fenetre.
Lors du chargement IE n'affriche pas l'URL passé en param ???

@+
Boss Hog


"Sébastien" wrote in message
news:3f8d3871$0$28904$
Erreur:
"GetDesktopWindow()"
---> fonction non définie


"Guy" a écrit dans le message de
news:061801c3930e$bc056040$
Salut,

voici une façon (pas la plus simple) via API:

'DANS UN MODULE
Private Declare Function ShellExecute Lib "shell32" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3

Public Sub RunShellExecute(sTopic As String, sFile As
Variant, _
sParams As Variant, sDirectory
As Variant, _
nShowCmd As Long)

Dim RetVal As Long
'execute the passed operation, passing
'the desktop as the window to receive
'any error messages
RetVal = ShellExecute(GetDesktopWindow(), _
sTopic, _
sFile, _
sParams, _
sDirectory, _
nShowCmd)

Call ShowWindow(RetVal, SW_SHOWNORMAL)
End Sub


-> Commande pour ouvrir une page WEB:
Call RunShellExecute("open", "http://www.google.fr", 0&,
0&, SW_SHOWNORMAL)

Tchao

Guy

>-----Message d'origine-----
>Bonjour,
>
>Ma question a déjà été posée de nombreuses fois mais je
ne parvient pas à
>retrouver la réponse.
>Comment ouvre-t-on une page web via un bouton ?
(www.google.fr)
>
>Un truc avec shell ? non ? je ne sais plus.
>Merci de votre aide.
>
>Sébastien
>
>
>.
>




Avatar
Hervé
Salut Sébastien,
Essai ceci :
Pour navigateur
Shell "Start.exe http://www.google.fr"
Pour messagerie
Shell "Start.exe mailto:?subject=Objet_du_message"

Hervé.

"Sébastien" a écrit dans le message news:
3f8d3871$0$28904$
Erreur:
"GetDesktopWindow()"
---> fonction non définie


"Guy" a écrit dans le message de
news:061801c3930e$bc056040$
Salut,

voici une façon (pas la plus simple) via API:

'DANS UN MODULE
Private Declare Function ShellExecute Lib "shell32" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3

Public Sub RunShellExecute(sTopic As String, sFile As
Variant, _
sParams As Variant, sDirectory
As Variant, _
nShowCmd As Long)

Dim RetVal As Long
'execute the passed operation, passing
'the desktop as the window to receive
'any error messages
RetVal = ShellExecute(GetDesktopWindow(), _
sTopic, _
sFile, _
sParams, _
sDirectory, _
nShowCmd)

Call ShowWindow(RetVal, SW_SHOWNORMAL)
End Sub


-> Commande pour ouvrir une page WEB:
Call RunShellExecute("open", "http://www.google.fr", 0&,
0&, SW_SHOWNORMAL)

Tchao

Guy

>-----Message d'origine-----
>Bonjour,
>
>Ma question a déjà été posée de nombreuses fois mais je
ne parvient pas à
>retrouver la réponse.
>Comment ouvre-t-on une page web via un bouton ?
(www.google.fr)
>
>Un truc avec shell ? non ? je ne sais plus.
>Merci de votre aide.
>
>Sébastien
>
>
>.
>




Avatar
jipi
Bonjour,

Ta solution fonctionne, merci.

et si l'on veut pousser un peu plus loin : faire un petit
téléchargement? le peut on?

jipi