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
| Private Sub CommandButton4_Click()
Dim NDF As String, NDF2 As String
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
NDF = ActiveWorkbook.Path & "C:\Documents and Settings\rm715079\Bureau\Inaptitude\formulaire3.dot"
NDF2 = ActiveWorkbook.Path & "C:\Documents and Settings\rm715079\Bureau" & Sheets("fiche agent").Range("B19").Text & ".doc"
On Error Resume Next
Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.Open(NDF, ReadOnly:=False)
With WordApp
.Visible = False
.Selection.Goto What:=wdGoToBookmark, Name:="nom"
.Selection.TypeText Text:=Sheets("fiche agent").Range("B21").Value
.Selection.Goto What:=wdGoToBookmark, Name:="prenom"
.Selection.TypeText Text:=Sheets("fiche agent").Range("B22").Value
.Selection.Goto What:=wdGoToBookmark, Name:="matricule"
.Selection.TypeText Text:=Sheets("fiche agent").Range("B19").Value
.Selection.Goto What:=wdGoToBookmark, Name:="prenom"
.Selection.TypeText Text:=Sheets("fiche agent").Range("B22").Value
.Selection.Goto What:=wdGoToBookmark, Name:="restriction1"
.Selection.TypeText Text:=Sheets("fiche agent").Range("F51").Value
.Selection.Goto What:=wdGoToBookmark, Name:="restriction2"
.Selection.TypeText Text:=Sheets("fiche agent").Range("F53").Value
.Selection.Goto What:=wdGoToBookmark, Name:="restriction3"
.Selection.TypeText Text:=Sheets("fiche agent").Range("F55").Value
End With
WordDoc.Application.ActiveDocument.SaveAs NDF2
WordApp.Application.Quit
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub |
Partager