Macro pour Word 97
La macro ci-dessous permet d'insérer dans un texte Word 97 un tableau indiquant la date et heure, la pression atmosphérique, l'humidité relative et la température stockées dans le dernier enregistrement de c:\FroggyPro\ExportAuto.txt généré par FroggyPro.exe version 1.31.
Cette fonction est très intéressante pour le personnel de laboratoire qui rédigeant un rapport d'essais doit indiquer les données barométrique dans lesquels ont eu lieu ces essais.
Simplement vous pouvez télécharger un document Word97 contenant cette macro en cliquant ici. Et renommer le en .doc.
Sub FroggyPro1()
'
' FroggyPro1 Macro
' Macro enregistrée le 24/01/02 par B10541-BRUNO
'
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeParagraph
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Documents.Open FileName:="c:\FroggyPro\ExportAuto.txt", ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
Selection.EndKey Unit:=wdStory
ActiveWindow.ActivePane.View.ShowAll = Not ActiveWindow.ActivePane.View. _
ShowAll
Selection.MoveLeft Unit:=wdCharacter, Count:=38, Extend:=wdExtend
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
ActiveWindow.Close
Selection.Paste
ActiveWindow.ActivePane.View.ShowAll = Not ActiveWindow.ActivePane.View. _
ShowAll
Selection.TypeParagraph
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, NumColumns:= _
4
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=16, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.Paste
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=18
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=6, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.HomeKey Unit:=wdLine
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Paste
Selection.HomeKey Unit:=wdLine
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=24
Selection.MoveRight Unit:=wdCharacter, Count:=6, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Paste
Selection.HomeKey Unit:=wdLine
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.EndKey Unit:=wdLine
Selection.MoveLeft Unit:=wdCharacter, Count:=6, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.EndKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Paste
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.EndKey Unit:=wdLine
Selection.MoveLeft Unit:=wdCharacter, Count:=39, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.TypeText Text:="Date Heure"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Pression (hPa)"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Humidité relative (%)"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Température (°C)"
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine
Selection.MoveLeft Unit:=wdCharacter, Count:=10, Extend:=wdExtend
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 12
Selection.MoveDown Unit:=wdLine, Count:=1
ActiveWindow.ActivePane.View.ShowAll = Not ActiveWindow.ActivePane.View. _
ShowAll
End Sub