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
| Sub Formulaire()
Dim Dte As Date
Dim j As Byte, m As Variant
Dim a As Integer
mee = Sheets("Historique.").Cells(3, 1)
m = Format(mee, "mmmm")
Dte = Sheets("Offre").Cells(5, 8)
j = Day(Dte)
a = Year(Dte)
Dim oWdApp As Object
Dim oWdDoc As Object
ligne = ActiveCell.Row
Sheets("Offre").Activate
relation = Sheets("Offre").Cells(9, 6)
Set oWdApp = CreateObject("Word.Application")
Set oWdDoc = oWdApp.Documents.Open("C:\Users\Sinfo\Desktop\Doc2.docx")
oWdApp.Visible = True
Range("A1:J47").Copy
oWdApp.Selection.PasteAndFormat (13)
Application.CutCopyMode = False
oWdApp.Visible = True
oWdApp.Selection.TypeParagraph
oWdApp.ActiveDocument.SaveAs Filename:="C:\Users\Sinfo\Desktop\" & relation & "(" & j & "_" & m & "_" & a & ")" & ".docx"
oWdApp.Quit 'On ferme
Set oWdApp = Nothing
Set oWdDoc = Nothing
Dim oWdApp_2 As Object
Dim oWdDoc_2 As Object
Set oWdApp_2 = CreateObject("Word.Application")
Set oWdDoc_2 = oWdApp_2.documents.Open("C:\Users\Sinfo\Desktop\" & relation & "(" & j & "_" & m & "_" & a & ")" & ".docx")
oWdApp_2.Visible = True
'On écrit la macro à partir du txt
oWdApp_2.VBE.VBProjects("Project").VBComponents.Item("ThisDocument").CodeModule.AddFromFile ("C:\Chemin du txt\Code.txt")
oWdDoc_2.Save
Set oWdApp_2 = Nothing
Set oWdDoc_2 = Nothing
End Sub |
Partager