1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
   | Dim fso, f, fc, fileWriter, NomAvant, NomApres, TRUC
set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set fso = CreateObject("Scripting.FileSystemObject") 
'Répertoire des éditions à modifier
Set f = fso.GetFolder("D:\Travail en cours\Test Editon 1")
Set fc = f.Files
For Each f1 in fc
 objWord.visible = False 
 
 Set objDoc = objWord.Documents.Open(f1.Path)
 'le code de la macro s'eécute ici, alors que je ne le veux pas !!!
 'Lecture du nom du dot rattaché
 NomAvant = objDoc.AttachedTemplate
 MsgBox ("Actuel:" & NomAvant)
 
 'Srvsieprod1 ?
 TRUC = Left(NomAvant,13)
 MsgBox("Nom de 13 de long : " & TRUC)
 If Left(NomAvant,13) = " \\tralala " Then
  'On met le nouveau chemin et on ajoute le reste
  TRUC = Right(NomAvant, (Len(NomAvant)-13))
  MsgBox("Reste de la chaine : " & TRUC)
  objDoc.AttachedTemplate = " \\choubidou " & Right(NomAvant, (Len(NomAvant)-13))
  objDoc.SaveAs(f.Path&"\S"&f1.name)
 End If
 objDoc.Close
 Set objDoc = nothing
Next | 
Partager