Ouvrir un .doc .xls ou .pdf avec vba ?

polompolom69 Messages postés 28 Date d'inscription samedi 9 octobre 2004 Statut Membre Dernière intervention 30 janvier 2012 - 16 mars 2005 à 00:48
polompolom69 Messages postés 28 Date d'inscription samedi 9 octobre 2004 Statut Membre Dernière intervention 30 janvier 2012 - 18 mars 2005 à 21:19
Bonjour,

j'ai une feuille excel qui répertorie une série de fiches techniques sauvegardée sous différents formats (.doc .xls ou .pdf ).
Je souhaiterais, réaliser un répertoire avec userform et pouvoir ouvrir l'une de ces fiche en cliquant sur un bouton.
Est-ce possible ?

Merci à celles et ceux qui pourrait m'aider dans ma démarche.

Bien à vous


Polompolom

5 réponses

cs_ITALIA Messages postés 2169 Date d'inscription vendredi 20 avril 2001 Statut Membre Dernière intervention 30 juin 2009 9
16 mars 2005 à 07:37
Il faut employer l'API ShellExecute :

Private Const SW_SHOWNORMAL = 1

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 Form_Load()

ShellExecute Me.hwnd, "open", "C:\Windows\File.txt", vbNullString, "C:\Windows\", SW_SHOWNORMAL

End Sub

It@li@
0
polompolom69 Messages postés 28 Date d'inscription samedi 9 octobre 2004 Statut Membre Dernière intervention 30 janvier 2012
16 mars 2005 à 23:29
Bonjour,


D'abord merci pour ta réponse et la précieuse aide que tu m'apporte.


J'ai néanmoins un petit soucis avec le code que tu m'as donné et que j'ai peut être mal compléter.


J'ai une erreur à l'exécution de mon module : "Utilisation incorrecte du mot clé 'Me'"

Voici le module tel que je l'ai écrit :

Private Const SW_SHOWNORMAL = 1


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
Sub Form_Load()


Dim fichieraouvrir As String


If Worksheets("Paramètres").Range("A5").Value = "M" Then
fichieraouvrir = "3" & usrcatalogue.txtcodemana.Value & "M " & usrcatalogue.txtintitu.Value



ShellExecute Me.hwnd, "open", fichieraouvrir, vbNullString, "C:", SW_SHOWNORMAL
End With



End Sub

Où est mon erreur s'il te plait ?

Cordialement


Polompolom
0
cs_ITALIA Messages postés 2169 Date d'inscription vendredi 20 avril 2001 Statut Membre Dernière intervention 30 juin 2009 9
17 mars 2005 à 08:19
ShellExecute 0, "open", fichieraouvrir, vbNullString, "C:", SW_SHOWNORMAL

It@li@
0
cs_ITALIA Messages postés 2169 Date d'inscription vendredi 20 avril 2001 Statut Membre Dernière intervention 30 juin 2009 9
17 mars 2005 à 08:20
ou simplement avec un Shell :

B = Shell("C:\Program Files\RealPlayer
ealjbox.exe F:\Ma musique\italia.mp3",
vbMaximizedFocus

It@li@
0

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

Posez votre question
polompolom69 Messages postés 28 Date d'inscription samedi 9 octobre 2004 Statut Membre Dernière intervention 30 janvier 2012
18 mars 2005 à 21:19
Merci pour tes précieux conseils. J'ai gardé la solution du ShellExecute.


Polompolom
0
Rejoignez-nous