Ouverture des fichiers via ComboBox

negrozoldik Messages postés 2 Date d'inscription mercredi 18 mars 2015 Statut Membre Dernière intervention 18 mars 2015 - 18 mars 2015 à 23:44
jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 - 19 mars 2015 à 00:20
Bonjour,


j aurai besoin de votre coup de pouce afin d'affecter l fichier sélectionner dans l comboBox au nom du fichier à ouvrir:

Private Sub CommandButton1_Click()
comboBox1.value= "nomfichier"
ThisWorkbook.FollowHyperlink "C:\ANAM\lois\nomfichier.pdf"
End Sub

merci

1 réponse

jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 344
19 mars 2015 à 00:20
Bonjour,

1 - Merci de bien vouloir utiliser la coloration syntaxique (les balises de code) lorsque tu postes du code sur le forum.
Explications disponibles ici :
http://codes-sources.commentcamarche.net/faq/10686-le-nouveau-codes-sources-comment-ca-marche#balises-code


2 - Essayes ça :

Private Sub CommandButton1_Click()
dim nomfichier  as string
nomfichier = comboBox1.value
ThisWorkbook.FollowHyperlink "C:\ANAM\lois\" & nomfichier & ".pdf"
End Sub



Et si avec FolloHyperLink ça ne fonctionne pas tu peux essayer avec ça :
Private Sub CommandButton1_Click()
Dim myShell As Object
dim nomfichier  as string
nomfichier = comboBox1.value

Set myShell =  CreateObject("WScript.Shell")
myShell.Run "C:\ANAM\lois\" & nomfichier & ".pdf"
End Sub

0
Rejoignez-nous