ticrain
Messages postés178Date d'inscriptionjeudi 15 mars 2007StatutMembreDernière intervention 2 janvier 2015
-
26 avril 2007 à 14:23
mortalino -
28 avril 2007 à 01:03
Je dois ouvrir des fichier excel et word que joré selectionner dans une listobox en appuyant sur un bouton:
est ce que qqun peut m'aider je c que shellexecute est efficace pour cela, g commencé un bout de code mais je c pas le finir ce que je peut vous dire c'est que les fichier .DOC et .XLS se trouve sur C:.
J'ai commencé se bout de code mais je c meme pas si je pars dans le bon sens? et surtout il est pas fini si qqun peut m'aider se serai sympa.
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)
...........
..........je sais plus après
drikce06
Messages postés2236Date d'inscriptionlundi 29 mai 2006StatutMembreDernière intervention29 mai 200810 26 avril 2007 à 15:13
J'ai écris ça pour le problème du hwnd mais ne marche pas encore mais ça vient d'autre chose que le hwnd maintenat!
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const SW_MAXIMIZE = 3
cs_Nicko11
Messages postés1141Date d'inscriptionmercredi 7 mars 2007StatutMembreDernière intervention19 septembre 20073 26 avril 2007 à 15:14
et bien pourquoi tu ne posts pas cela. Tu ne nous dis pas ce que tu fais et si tu as un pb precis. Tu crois pas qu'on aurais gagné du temps si tu nous l'avais dis.
drikce06
Messages postés2236Date d'inscriptionlundi 29 mai 2006StatutMembreDernière intervention29 mai 200810 26 avril 2007 à 15:19
Pour trouver le hwnd:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim hwnd As Long
hwnd = FindWindow(vbNullString, Me.Name)
Drikce 06
Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
ticrain
Messages postés178Date d'inscriptionjeudi 15 mars 2007StatutMembreDernière intervention 2 janvier 2015 26 avril 2007 à 15:23
J'ai cela maintenant et j'ai toujours la même erreur au niveau de ME.hwnd
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub CommandButton2_Click()
Dim nomdoc As String
Dim hwnd As Long
hwnd = FindWindow(vbNullString, Me.Name)
nomdoc = ListBox1.List(ListBox1.ListIndex)
Dim chemindoc As String
chemindoc = "c:" & nomdoc
Call ShellExecute(Me.hwnd, "open", nomdoc, vbNullString, vbNullString)
End Sub
Je te rappelle qu’on n’est pas tes sous-traitants. Prends la peine de chercher et d'assemble ce qu'on t'a donné que tu auris du trouver toi même, tu a la tout ce qu'il te faut.
Tu ne prends pas en compte les réponses qu'on te donne. Tu ne lis rien. Tu ne fais aucun effort.
Moi j'abandonne.
jrivet
Messages postés7392Date d'inscriptionmercredi 23 avril 2003StatutMembreDernière intervention 6 avril 201260 26 avril 2007 à 15:38
Salut,
J'étais en réunion désolé pour le retard.
Post tirée de ce sujet (Puis plus de nouvelles car soit dissant ca marchait).
PITIE [auteurdetail.aspx?ID= 1007130 ticrain TESTE LE CODE QUE JE TE RPOPOSE ON VA PAS PASSER TROIS SEMAINES SUR TON SUJET.]
Une petite précision dans le code ci dessous lors de l'appel de ShellExecute la variable Fichier doit contenir LE CHEMIN COMPLET DU FICHIER pas un simple toto.xls
Re : OUVRIR FICHIER à PARTIR d'une LISTOBOX
par : [auteurdetail.aspx?ID =89254 jrivet]([membreclub.aspx Membre Club ]) le 24/04/2007 10:13:52
, [infomsg.aspx?ID= 928376&p=2#reponsemsg Rép.], [javascript:void(0); MP], [infomsgm_JRIVET_89254.aspx 3503 msg], 3633 msg CS
[auteurdetail.aspx?ID=89254 ]
Salut,
Aller version VBA testée (qu'on en finisse)
Un UserForm, Une ListBox renommé en List1 et HOP.
J'espère qu moins que tu utilises bien un ListBox
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 Const SW_MAXIMIZE = 3
Private Sub List1_Click()
Dim Fichier As String
Fichier = List1.List(List1.ListIndex)
Call ShellExecute(0, "open", Fichier, vbNullString, vbNullString, SW_MAXIMIZE)
End Sub<hr />
Private Sub UserForm_Activate()
Dim Fichier As String
Dim Repertoire As String
Repertoire = "C:\Test\"
Fichier = Dir(Repertoire & "*.*")
While Fichier <> ""
Call List1.AddItem(Repertoire & Fichier)
Fichier = Dir
Wend
End Sub<hr />, ----
[code.aspx?ID=41455 By Renfield]
cs_Nicko11
Messages postés1141Date d'inscriptionmercredi 7 mars 2007StatutMembreDernière intervention19 septembre 20073 26 avril 2007 à 15:41
Et bien voila banane, comme quoi on peut quand on veut, je n'avais pas la moindre idee de comment faire et la j'ai reussi tout seul
Option Compare Database
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 Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
ticrain
Messages postés178Date d'inscriptionjeudi 15 mars 2007StatutMembreDernière intervention 2 janvier 2015 26 avril 2007 à 15:46
dsl mais moi sa ne marche pas voila ce que j'ai maintenant que tu m'a donné ton code:
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)
Call ShellExecute(Me.hwnd, vbNullString, nomdoc, vbNullString, "C:", SW_SHOWNORMAL)
End Sub
jrivet
Messages postés7392Date d'inscriptionmercredi 23 avril 2003StatutMembreDernière intervention 6 avril 201260 26 avril 2007 à 15:48
Re,
ON T'A DIT QU IL N Y A PAS DE Me.hwnd DANS VBA D OU MON POST
ALORS T A TESTE CA DONNE QUOI..............
Post tirée de ce sujet (Puis plus de nouvelles car soit dissant ca marchait).
PITIE [auteurdetail.aspx?ID= 1007130 ticrain TESTE LE CODE QUE JE TE RPOPOSE ON VA PAS PASSER TROIS SEMAINES SUR TON SUJET.]
Une
petite précision dans le code ci dessous lors de l'appel de
ShellExecute la variable Fichier doit contenir LE CHEMIN COMPLET DU
FICHIER pas un simple toto.xls
Re : OUVRIR FICHIER à PARTIR d'une LISTOBOX par : [auteurdetail.aspx?ID =89254 jrivet]([membreclub.aspx Membre Club ]) le 24/04/2007 10:13:52
, [infomsg.aspx?ID=928376&p=2#reponsemsg Rép.], [void%280%29; MP], [infomsgm_JRIVET_89254.aspx 3503 msg], 3633 msg CS
[auteurdetail.aspx?ID=89254 ] Salut,
Aller version VBA testée (qu'on en finisse)
Un UserForm, Une ListBox renommé en List1 et HOP.
J'espère qu moins que tu utilises bien un ListBox
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 Const SW_MAXIMIZE = 3
Private Sub List1_Click()
Dim Fichier As String
Fichier = List1.List(List1.ListIndex)
Call ShellExecute(0, "open", Fichier, vbNullString, vbNullString, SW_MAXIMIZE)
End Sub<hr />
Private Sub UserForm_Activate()
Dim Fichier As String
Dim Repertoire As String
Repertoire = "C:\Test\"
Fichier = Dir(Repertoire & "*.*")
While Fichier <> ""
Call List1.AddItem(Repertoire & Fichier)
Fichier = Dir
Wend
End Sub<hr />, ----
[code.aspx?ID=41455 By Renfield]
ticrain
Messages postés178Date d'inscriptionjeudi 15 mars 2007StatutMembreDernière intervention 2 janvier 2015 26 avril 2007 à 15:57
voici ce que j'ai maintenant mais rien ne se passe:
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 Const SW_MAXIMIZE = 3
Private Sub listbox1_Click()
Dim nomdoc As String
nomdoc = ListBox1.List(ListBox1.ListIndex)
Call ShellExecute(0, "open", nomdoc, vbNullString, "C:", SW_SHOWNORMAL)
End Sub
Private Sub user_activate()
Dim Fichier As String
Dim Repertoire As String
Repertoire = "C:"
Fichier = Dir(Repertoire & "*.*")
While Fichier <> ""
Call ListBox1.AddItem(Repertoire & Fichier)
Fichier = Dir
Wend
End Sub
cs_Nicko11
Messages postés1141Date d'inscriptionmercredi 7 mars 2007StatutMembreDernière intervention19 septembre 20073 26 avril 2007 à 15:57
Par contre Jrivet, je sais pas pourquoi mais moi sans le Me.hwnd, ca ne fonctionne pas. Sinon avec, ca fonctionne nickel.
Dis moi 1007130 ticrain, meme si tu m'enerves comme c'est pas permis, je me dis que ca servira a quelqu'un.
Tu crées un projet access, tu crée un formuaire en mode création. Ensuite, tu clique sur l'editeur de VB.
dans l'evenement Form_Load de ton formulaire tu copies ce code, avec le bon fichier au bon chemin et la bonne extention du fichier
Option Compare Database
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 Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long