URGENT : Problèmes d'espaces dans un chemin de fichier!

cs_boujou Messages postés 3 Date d'inscription jeudi 12 septembre 2002 Statut Membre Dernière intervention 7 novembre 2002 - 7 nov. 2002 à 11:27
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 - 7 nov. 2002 à 11:46
Bonjour à tous,

Voilà mon problème, j'essaye de faire ouvrir à Excel un fichier sur le
réseau :

Set wkClasseur = xlApp.Workbooks.Open(PathIndex)

PathIndex représentant la variabale contenant le chemin de mon fichier. Cela
fonctionne trés bien sauf lorsque le chemin de mon fichier contient des
espaces (que je ne peux d'ailleurs en aucun cas les enlever.)

J'ai aussi essayé cela :

Set wkClasseur = xlApp.Workbooks.Open(chr(34) & PathIndex &
chr(34))

Mais là cela ne fonctionne pas du tout.

Quelqu'un a t-il une idée pour me dépanner? C'est très urgent, merci
d'avance pour vos réponses!

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
7 nov. 2002 à 11:46
Bonjour,

exemple pour un répertoire à rallonge
Dim Fso, path, fichier, fichiers, WshShell
path = "E:\Affaires\EUROFACTOR - AP02N008\4.3 Formulaires\Formulaires spécifiques"

Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set dossier = fso.GetFolder(path)
Set fichiers = Dossier.Files

For Each fichier in fichiers
'MsgBox "shortPath=" & fichier.ShortPath & vbCrLf & "Path=" & fichier.Path
'MsgBox "shortName=" & fichier.ShortName & vbCrLf & "Name=" & fichier.Name
If Left(fichier.name,19) = "Main courante Ifdex" Then
WshShell.Run fichier.ShortPath
WScript.Sleep(3000)
WshShell.SendKeys "^p"
WScript.Sleep(2000)
WshShell.SendKeys "{ENTER}" 'imprimer => ok
WScript.Sleep(3000)
WshShell.SendKeys "%(fq)" 'fermeture du document
WScript.Sleep(3000)
End If
0
Rejoignez-nous