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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
| Sub Courrier_Word()
Dim mapp As Word.Application
Dim Mdoc As Word.Document
Dim Mchemindoc As String
Dim MRelance As String
'ChDrive "G"'
Mchemindoc = "\\amcristal.local\am\RedirectedFolders\f.nallet\Bureau\Docs\Publipostage\Macro Source\Model Lettre Publi\"
ChDir Mchemindoc
Set mapp = New Word.Application
If mZAE = True Then
mapp.Documents.Open Filename:=Mchemindoc & "Matrice Pré-Relance.docx"
If mZE = True Then
mapp.Documents.Open Filename:=Mchemindoc & "Matrice Relance.docx"
If mZE2 = True Then
mapp.Documents.Open Filename:=Mchemindoc & "Matrice Relance2.docx"
Else
mapp.Documents.Open Filename:=Mchemindoc & "Matrice MED.docx"
End If
Set Mdoc = mapp.ActiveDocument
mapp.Visible = True 'Excel screen updating sans desactiver les msgbx utilisable que pdt pilotage
mapp.Options.ReplaceSelection = False 'Mode refrappe par defaut d'ou False pour desactiver
mapp.Selection.HomeKey unit:=wdStory 'positionnement haut doc
If mZAE = True Then
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Nomcli_AE"
If MNomCli <> "0" Then mapp.Selection.TypeText Text:=MNomCli
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Adr1_AE"
If MAdr1 <> "0" Then mapp.Selection.TypeText Text:=MAdr1
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Adr2_AE"
If MAdr2 <> "0" Then mapp.Selection.TypeText Text:=MAdr2
mapp.Selection.Goto what:=wdGoToBookmark, Name:="CPCity_AE"
If MCPCity <> "0" Then mapp.Selection.TypeText Text:=MCPCity
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Country_AE"
If MCountry <> "0" Then mapp.Selection.TypeText Text:=MCountry
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Echeance_AE"
If MdateEch <> "0" Then mapp.Selection.TypeText Text:=MdateEch
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Collector_AE"
If MCollector <> "0" Then mapp.Selection.TypeText Text:=MCollector
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Tel_AE"
If MTel <> "0" Then mapp.Selection.TypeText Text:=MTel
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Fax_AE"
If MFax <> "0" Then mapp.Selection.TypeText Text:=MFax
If mZE = True Then
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Nomcli_E"
If MNomCli <> "0" Then mapp.Selection.TypeText Text:=MNomCli
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Adr1_E"
If MAdr1 <> "0" Then mapp.Selection.TypeText Text:=MAdr1
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Adr2_E"
If MAdr2 <> "0" Then mapp.Selection.TypeText Text:=MAdr2
mapp.Selection.Goto what:=wdGoToBookmark, Name:="CPCity_E"
If MCPCity <> "0" Then mapp.Selection.TypeText Text:=MCPCity
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Country_E"
If MCountry <> "0" Then mapp.Selection.TypeText Text:=MCountry
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Collector_E"
If MCollector <> "0" Then mapp.Selection.TypeText Text:=MCollector
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Tel_E"
If MTel <> "0" Then mapp.Selection.TypeText Text:=MTel
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Fax_E"
If MFax <> "0" Then mapp.Selection.TypeText Text:=MFax
If mZE2 = True Then
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Nomcli_E"
If MNomCli <> "0" Then mapp.Selection.TypeText Text:=MNomCli
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Adr1_E"
If MAdr1 <> "0" Then mapp.Selection.TypeText Text:=MAdr1
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Adr2_E"
If MAdr2 <> "0" Then mapp.Selection.TypeText Text:=MAdr2
mapp.Selection.Goto what:=wdGoToBookmark, Name:="CPCity_E"
If MCPCity <> "0" Then mapp.Selection.TypeText Text:=MCPCity
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Country_E"
If MCountry <> "0" Then mapp.Selection.TypeText Text:=MCountry
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Collector_E"
If MCollector <> "0" Then mapp.Selection.TypeText Text:=MCollector
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Tel_E"
If MTel <> "0" Then mapp.Selection.TypeText Text:=MTel
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Fax_E"
If MFax <> "0" Then mapp.Selection.TypeText Text:=MFax
Else
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Nomcli_E"
If MNomCli <> "0" Then mapp.Selection.TypeText Text:=MNomCli
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Adr1_E"
If MAdr1 <> "0" Then mapp.Selection.TypeText Text:=MAdr1
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Adr2_E"
If MAdr2 <> "0" Then mapp.Selection.TypeText Text:=MAdr2
mapp.Selection.Goto what:=wdGoToBookmark, Name:="CPCity_E"
If MCPCity <> "0" Then mapp.Selection.TypeText Text:=MCPCity
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Country_E"
If MCountry <> "0" Then mapp.Selection.TypeText Text:=MCountry
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Collector_E"
If MCollector <> "0" Then mapp.Selection.TypeText Text:=MCollector
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Tel_E"
If MTel <> "0" Then mapp.Selection.TypeText Text:=MTel
mapp.Selection.Goto what:=wdGoToBookmark, Name:="Fax_E"
If MFax <> "0" Then mapp.Selection.TypeText Text:=MFax
End If
'si pas de variable rattaché = mapp.selection.typetext text:="blablabal"
Mdoc.PrintOut
Mdoc.Close SaveChanges:=wdDoNotSaveChanges
'dans le cas de sauvegarde reseau Mdoc.saveas filename:= "G:\...
'Mdoc.Close
mapp.Quit 'necessité de fermé tous les docs avant de quitter.
'decharger la memoire
Set Mdoc = Nothing
Set mapp = Nothing
End Sub |
Partager