Ouvrir un fichier exel avec un vbScript

Werdna Messages postés 1 Date d'inscription jeudi 23 octobre 2003 Statut Membre Dernière intervention 18 avril 2008 - 18 avril 2008 à 16:31
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 - 19 avril 2008 à 08:45
Bonjour a tous

Je cherche à faire apparaitre un explorateur pour que mes utilisateurs puissent choisir l'emplacement du fichier exel qui va etre traité par mon scripte.
Pour l'instant, je sais faire apparaitre une boite de dialogue et mes utilisateurs doivent entrer le chemin complet de l'emplacement du fichier exel a traité.
Es ce possible en VBS?

D'avance merci de vos réponces.
Nico

1 réponse

cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
19 avril 2008 à 08:45
 Bonjour,

L'objet CommonDialog pourrait être une solution.

Exemple:
Option Explicit
Dim objDialog, objExcel, intResult

Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Selectionner un fichier Excel|*.xls"
objDialog.FilterIndex = 1
objDialog.InitialDir = "F:"
intResult = objDialog.ShowOpen

If intResult = 0 Then WScript.Quit

Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open objDialog.FileName  
objExcel.Visible = True
objExcel.DisplayAlerts = False

MsgBox "Fichier ouvert",,objDialog.FileName

objExcel.Quit
Set objExcel = Nothing
Set objDialog = Nothing

jean-marc
0
Rejoignez-nous