VBA fonctionnement de dir

Résolu
bonjour :),
allons doit au but voici mon code:

Dim verif As String

Dim appExcel As Excel.Application
Dim wbk As Excel.Workbook, wsht As Excel.Worksheet

chemin = "C:\Users\yannick\Desktop\"
fich = fichier.Value
direction = chemin & fich

verif = dir(direction)
If verif = "" Then
MsgBox ("le fichier n'existe pas")
Exit Sub
Else

Set appExcel = New Excel.Application
appExcel.Visible = True
Set wbk = appExcel.Workbooks.Open(direction, ReadOnly:=True)
Set wsht = wbk.Worksheets(1)

la variable verif prend toujours la valeur : ""
alors que la variable direction contient le bon chemin puisque ce code ouvre le fichier sans aucun problème:

Dim appExcel As Excel.Application
Dim wbk As Excel.Workbook, wsht As Excel.Worksheet

chemin = "C:\Users\yannick\Desktop\"
fich = fichier.Value
direction = chemin & fich
Set appExcel = New Excel.Application
appExcel.Visible = True
Set wbk = appExcel.Workbooks.Open(direction, ReadOnly:=True)
Set wsht = wbk.Worksheets(1)

j'ai surement du mal comprendre le fonctionnement de dir la variable, vérif ne devrait elle pas valoir l'adresse du fichier?? :)

4 réponses

  1. bien vue je travailler toujours sur du xlsx j'avais pas besoin de préciser l'extension mais la c'est un fichier xsl 2003.....

    merci beaucoup
    0