Bonjour,
j utilise excel pour remplir des doc excel et word...
pour le moment je n ai essaye que sur les documents word.
lorsque je n ai qu un seul document sous mon repertoire, cela fonctionne des que j en ai deux ou trois plus rien ne va...
voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Select Case True Case UserForm1.combobox2 = "A" And Sheet2.Meetings_reports_third_A Directory = New_project & "\" & Sheet2.Range("Project_Management") & "\" & Sheet2.Range("Correspondence_Reports") & "\" & Sheet2.Range("Meetings___Reports___3rd_Party") & "\" Set Worddoc = WordApp.Documents.Open(Directory & "MOM 3rd party.doc") With Worddoc .Bookmarks("ProjectName").Range.Text = UserForm1.TextBox3.Value .Bookmarks("ProjectManager").Range.Text = UserForm1.combobox1.Value .Bookmarks("Customer_PO_reference").Range.Text = UserForm1.TextBox6.Value .Bookmarks("ProjectNumber").Range.Text = UserForm1.TextBox1.Value .Bookmarks("ProjectNumber1").Range.Text = UserForm1.TextBox1.Value End With Worddoc.Save WordApp.Quit Set Worddoc = Nothing Set Worddoc = WordApp.Documents.Open(Directory & "Progress report 3rd party.doc") With Worddoc .Bookmarks("ProjectName").Range.Text = UserForm1.TextBox3.Value .Bookmarks("ProjectManager").Range.Text = UserForm1.combobox1.Value .Bookmarks("Customer_PO_reference").Range.Text = UserForm1.TextBox6.Value .Bookmarks("ProjectNumber").Range.Text = UserForm1.TextBox1.Value .Bookmarks("ProjectNumber1").Range.Text = UserForm1.TextBox1.Value End With Worddoc.Save WordApp.Quit Set Worddoc = Nothing Case UserForm1.combobox2 = "B" And Sheet2.Meetings_reports_third_B Directory = New_project & "\" & Sheet2.Range("Project_Management") & "\" & Sheet2.Range("Correspondence_Reports") & "\" & Sheet2.Range("Meetings___Reports___3rd_Party") & "\" Set Worddoc = WordApp.Documents.Open(Directory & "MOM 3rd party.doc") With Worddoc .Bookmarks("ProjectName").Range.Text = UserForm1.TextBox3.Value .Bookmarks("ProjectManager").Range.Text = UserForm1.combobox1.Value .Bookmarks("Customer_PO_reference").Range.Text = UserForm1.TextBox6.Value .Bookmarks("ProjectNumber").Range.Text = UserForm1.TextBox1.Value .Bookmarks("ProjectNumber1").Range.Text = UserForm1.TextBox1.Value End With Worddoc.Save WordApp.Quit Set Worddoc = Nothing Set Worddoc = WordApp.Documents.Open(Directory & "Progress report 3rd party.doc") With Worddoc .Bookmarks("ProjectName").Range.Text = UserForm1.TextBox3.Value .Bookmarks("ProjectManager").Range.Text = UserForm1.combobox1.Value .Bookmarks("Customer_PO_reference").Range.Text = UserForm1.TextBox6.Value .Bookmarks("ProjectNumber").Range.Text = UserForm1.TextBox1.Value .Bookmarks("ProjectNumber1").Range.Text = UserForm1.TextBox1.Value End With Worddoc.Save WordApp.Quit Set Worddoc = Nothing Case UserForm1.combobox2 = "C" And Sheet2.Meetings_reports_third_C Directory = New_project & "\" & Sheet2.Range("Project_Management") & "\" & Sheet2.Range("Correspondence_Reports") & "\" & Sheet2.Range("Meetings___Reports___3rd_Party") & "\" Set Worddoc = WordApp.Documents.Open(Directory & "MOM 3rd party.doc") With Worddoc .Bookmarks("ProjectName").Range.Text = UserForm1.TextBox3.Value .Bookmarks("ProjectManager").Range.Text = UserForm1.combobox1.Value .Bookmarks("Customer_PO_reference").Range.Text = UserForm1.TextBox6.Value .Bookmarks("ProjectNumber").Range.Text = UserForm1.TextBox1.Value .Bookmarks("ProjectNumber1").Range.Text = UserForm1.TextBox1.Value End With Worddoc.Save WordApp.Quit Set Worddoc = Nothing Set Worddoc = WordApp.Documents.Open(Directory & "Progress report 3rd party.doc") With Worddoc .Bookmarks("ProjectName").Range.Text = UserForm1.TextBox3.Value .Bookmarks("ProjectManager").Range.Text = UserForm1.combobox1.Value .Bookmarks("Customer_PO_reference").Range.Text = UserForm1.TextBox6.Value .Bookmarks("ProjectNumber").Range.Text = UserForm1.TextBox1.Value .Bookmarks("ProjectNumber1").Range.Text = UserForm1.TextBox1.Value End With Worddoc.Save WordApp.Quit Set Worddoc = Nothing Case UserForm1.combobox2 = "D" And Sheet2.Meetings_reports_third_D Directory = New_project & "\" & Sheet2.Range("Project_Management") & "\" & Sheet2.Range("Correspondence_Reports") & "\" & Sheet2.Range("Meetings___Reports___3rd_Party") & "\" Set Worddoc = WordApp.Documents.Open(Directory & "MOM 3rd party.doc") With Worddoc .Bookmarks("ProjectName").Range.Text = UserForm1.TextBox3.Value .Bookmarks("ProjectManager").Range.Text = UserForm1.combobox1.Value .Bookmarks("Customer_PO_reference").Range.Text = UserForm1.TextBox6.Value .Bookmarks("ProjectNumber").Range.Text = UserForm1.TextBox1.Value .Bookmarks("ProjectNumber1").Range.Text = UserForm1.TextBox1.Value End With Worddoc.Save WordApp.Quit Set Worddoc = Nothing Set Worddoc = WordApp.Documents.Open(Directory & "Progress report 3rd party.doc") With Worddoc .Bookmarks("ProjectName").Range.Text = UserForm1.TextBox3.Value .Bookmarks("ProjectManager").Range.Text = UserForm1.combobox1.Value .Bookmarks("Customer_PO_reference").Range.Text = UserForm1.TextBox6.Value .Bookmarks("ProjectNumber").Range.Text = UserForm1.TextBox1.Value .Bookmarks("ProjectNumber1").Range.Text = UserForm1.TextBox1.Value End With Worddoc.Save WordApp.Quit Set Worddoc = Nothing End Select
merci de votre future aide
Tom
Partager