Inserer du texte via vbs

Inserer du texte via vbs - VB/VBA/VBS - Programmation

Marsh Posté le 05-06-2009 à 16:42:24    

Bonjour,
 
Je cherche via un vbs à insérer du texte dans un document Word.
 
Mon probléme est le suivant: certaines des chaines à insérer dépassent les 255 caractéres, comment déclarer la variable en variable de type texte.
D'autre part, je souhaite ajouter des retours chariots entre chacune des dates mais cela ne fonctionne pas.
 
Si l'un de vous a une idée de génie, je suis preneuse d'autant que je suis plus que novice en vba et vbs.
 
Merci par avance pour votre aide.

Code :
  1. Const wdReplaceAll = 2
  2. path = "C:\Documents and Settings\All Users\Application Data\OE\OEWord549806202.doc"
  3. Set objWord = CreateObject("Word.Application" )
  4. Dim objWordDoc
  5. Set objWordDoc=objWord.Documents.open(path)
  6. objWord.Visible = true
  7. With objWord.Selection.Find
  8. .ClearFormatting
  9. .Text = "<!-- (Patients)Nom usuel Pat. -->"
  10. With .Replacement
  11. .ClearFormatting
  12. .Text ="LOSCO"
  13. End With
  14. .Execute , , , , , , , , , , wdReplaceAll
  15. End With
  16. With objWord.Selection.Find
  17. .ClearFormatting
  18. .Text = "<!-- (Patients)Prénom Pat. -->"
  19. With .Replacement
  20. .ClearFormatting
  21. .Text ="Pablo"
  22. End With
  23. .Execute , , , , , , , , , , wdReplaceAll
  24. End With
  25. With objWord.Selection.Find
  26. .ClearFormatting
  27. .Text = "<!-- (Lignes de Rendez-vous)Date -->"
  28. With .Replacement
  29. .ClearFormatting
  30. .Text ="15/09/2004*07/04/2004*20/04/2004*07/04/2004*07/05/2004*24/05/2004*02/07/2004*22/06/2004*16/07/2004*08/09/2004*22/10/2004*03/12/2004*07/01/2005*14/01/2005*08/03/2005*20/06/2006*18/08/2006*26/09/2006*06/10/2006*17/11/2006*04/12/2006*15/04/2005*27/05/2005*29/06/2005*30/08/2005*11/10/2005*22/11/2005*14/02/2006*30/04/2007*28/03/2006*09/05/2006*11/12/2006*11/12/2006*06/02/2007*10/01/2006*14/02/2006*"
  31. End With
  32. .Execute , , , , , , , , , , wdReplaceAll
  33. End With
  34. ScreenUpdating=True
  35. objWord.ScreenRefresh
  36. objWordDoc.Save
  37. objWord.NormalTemplate.Saved = True
  38. Set objWordDoc = nothing
  39. Set objWord = nothing


 

Reply

Marsh Posté le 05-06-2009 à 16:42:24   

Reply

Marsh Posté le 07-06-2009 à 22:10:05    

Bonjour,
 
Pour insérer un saut de ligne, la solution généralement consiste à utiliser la fonction chr (chr(10) en l'occurence)
 
Mais permettez moi un peu de pub : ne perdez pas de temps à programmer, je peux le faire pour vous à un taux raisonnable,
 
Contactez moi sur bolontapia@telepolis.com
 
Pro du VBA

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed