SHELLEXECUTE

ticrain Messages postés 178 Date d'inscription jeudi 15 mars 2007 Statut Membre Dernière intervention 2 janvier 2015 - 26 avril 2007 à 11:52
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 - 26 avril 2007 à 17:15
Bonjour à tous voila sa fait un petit moment que je cherche pour ouvrir un programme quelconque avec la commande shellexecute.

G plusieurs fichier word et excel sur le C:. C 'est fichier apparaissent dans une listbox donc je peut avoir soi des fichier .doc ou excel, j'aimerai que mon prog puisse s'executer avec la bonne application en focntion de se que j'a choisi dans la listbox 1 voila se que j'ai commencé à faire:

Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" (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
Private Const SW_MAXIMIZE = 3


Private Sub CommandButton2_Click()
Dim nomdoc As String
Dim chemindoc As String
nomdoc = ListBox1.List(ListBox1.ListIndex)
chemindoc = "c:\&nomdoc"
Call ShellExecute(0, "open", nomdoc, vbNullString, vbNullString, SW_MAXIMIZE)
End Sub

il ne se passe rien il n'ouvre rien j'ai du oublier des truc

10 réponses

drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
26 avril 2007 à 11:54
Salut, en .Net les types long sont à changer en integer!
Sinon va sur www.codyx.org et tu trouveras un snippet pour faire ça à la façon .Net (startprocess)

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
1
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
26 avril 2007 à 11:55
http://www.codyx.org/snippet_ouvrir-document-lancer-executable_25.aspx#69




 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
26 avril 2007 à 14:43
Private Sub CommandButton2_Click()
Dim nomdoc As String
Dim chemindoc As String
nomdoc = ListBox1.List(ListBox1.ListIndex)
chemindoc = "c:" & nomdoc

Call ShellExecute(0, "open", nomdoc, vbNullString, vbNullString, SW_MAXIMIZE)
End Sub

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0
ticrain Messages postés 178 Date d'inscription jeudi 15 mars 2007 Statut Membre Dernière intervention 2 janvier 2015
26 avril 2007 à 14:46
sa va marché avec ca tu crois il va 'mouvri les xls et les doc?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
26 avril 2007 à 14:48
Call ShellExecute(Me.hwnd, "open", nomdoc, vbNullString, vbNullString, SW_MAXIMIZE)

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0
ticrain Messages postés 178 Date d'inscription jeudi 15 mars 2007 Statut Membre Dernière intervention 2 janvier 2015
26 avril 2007 à 14:51
il n'est pas d'accord il me marque erreur de compilation pour le (ME.hwnd

voici ce que g maintenant:

Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" 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


Private Sub CommandButton2_Click()
Dim nomdoc As String
nomdoc = ListBox1.List(ListBox1.ListIndex)
Dim chemindoc As String
chemindoc = "c:" & nomdoc
Call ShellExecute(Me.hwnd, "open", nomdoc, vbNullString, vbNullString, SW_MAXIMIZE)
End Sub
0
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
26 avril 2007 à 14:59
T'es en quoi VB6, VB.net ou VBA?

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0
ticrain Messages postés 178 Date d'inscription jeudi 15 mars 2007 Statut Membre Dernière intervention 2 janvier 2015
26 avril 2007 à 15:01
je suis en VBA drickce 06 et à mon avis VBA ne connai pas cet argument!
0
zavier666 Messages postés 266 Date d'inscription mardi 7 septembre 2004 Statut Membre Dernière intervention 30 avril 2009 1
26 avril 2007 à 17:14
Si tu cherche des conseils sur shellexecute:

va sur mon site rubrique shell32.dll


slts!


--------------------------------------------------------------

Toujours + de VB6 et d'API => API @ la Loupe


Le site s'est offert une nouvelle interface, à voir sans faute
0
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
26 avril 2007 à 17:15
lol! zavier666  t'arrives un peu tard va voir le topic à 78 post un peu plus haut!

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0
Rejoignez-nous