Bonjour,
je gère une base de données de clients sous Access.
Je desire rediger des compte rendu Word (export de Access vers Word) et faire en sorte que ces CR (Compte Rendus) soient liés a chaque fiche client sous Access.
J'ai reussi a faire un bouton (en VB) sous Access qui, sur clic, ouvre un fichier Word et recupere les infos de la fiche client.
Ceci grace un fichier.dot dans lequel j'ai placé des signets, et grace également à du code VB.
Mais je rencopntre qques difficultés pour poursuivre :
> ce fichier Word s'intitule Document1.doc aprés fusion..
> De plus il n'est pas lié à ma fiche client Access.
Comment faire ?
Je pensais :
-creer un champs "CR" dans ma table client qui recuperait le "Numéro" du client (champs unique) + ".doc" derriere. Ceci fait il suffirait de recuperer cette valeur pour renomer le Document1.doc emis (hypothese...)
-faire en sorte que cette valeur "CR" apparraissent dans mon formulaire pour pouvoir rappeler le CR en question aprés saisie... (lien hypertexte ?)
Bref je patauge gravement et j'appele ô secours une bonne âme !![]()
Mon code vb sous access, créant le Document1.doc (via le modele de document *.dot) afin d'exporter les données du client vers word :
(PS : l'export vers Word est un passage obligé)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 Private Sub Commande595_Click() On Error GoTo Err_Commande595_Click Dim objWord As Word.Application Dim doc As Word.Document Dim strSQL As String Dim strNumero As String Dim strCommune As String Dim strCP As String Dim strEmail As String Dim strEquipement As String Dim dhDate As Date Dim strFax As String Dim strTelephone As String Dim strHoraires As String Dim strAction As String Dim strSuivi As String Dim strFonction1 As String Dim strFonction2 As String Dim strFonction3 As String Dim strNom1 As String Dim strNom2 As String Dim strNom3 As String Dim strHoraires1 As String Dim strHoraires2 As String Dim strHoraires3 As String Dim strContacts As String strSQL = "SELECT * FROM Contacts " _ & "WHERE [Numéro]=" & Me!Numéro Set rst = CurrentDb.OpenRecordset(strSQL) With rst strCommune = Nz(.Fields("Commune 01")) strCP = Nz(.Fields("CP")) strEmail = Nz(.Fields("email")) strEquipement = Nz(.Fields("Equipement")) strDate = Nz(.Fields("Date")) strFax = Nz(.Fields("fax")) strTelephone = Nz(.Fields("Telephone")) strHoraires = Nz(.Fields("Horaires")) strAction = Nz(.Fields("Action")) strSuivi = Nz(.Fields("Suivi")) strFonction1 = Nz(.Fields("Fonction 1")) strFonction2 = Nz(.Fields("Fonction 2")) strFonction3 = Nz(.Fields("Fonction 3")) strNom1 = Nz(.Fields("Nom 1")) strNom2 = Nz(.Fields("Nom 2")) strNom3 = Nz(.Fields("Nom 3")) strHoraires1 = Nz(.Fields("Horaires 1")) strHoraires2 = Nz(.Fields("Horaires 2")) strHoraires3 = Nz(.Fields("Horaires 3")) strContacts = Nz(.Fields("Contacts")) .Close End With On Error Resume Next Set objWord = GetObject(, "Word.application") If Err = 429 Then Set objWord = New Word.Application End If On Error GoTo 0 With objWord .Visible = True Set doc = .Documents.Add("C:\Documents and Settings\Administrateur\Mes documents\DAVID\FICHES complete.dot") With doc.Bookmarks .Item("commune").Range.Text = strCommune .Item("cp").Range.Text = strCP .Item("email").Range.Text = strEmail .Item("equipement").Range.Text = strEquipement .Item("date").Range.Text = strDate .Item("fax").Range.Text = strFax .Item("telephone").Range.Text = strTelephone .Item("horaires").Range.Text = strHoraires .Item("action").Range.Text = strAction .Item("suivi").Range.Text = strSuivi .Item("fonction1").Range.Text = strFonction1 .Item("fonction2").Range.Text = strFonction2 .Item("fonction3").Range.Text = strFonction3 .Item("nom1").Range.Text = strNom1 .Item("nom2").Range.Text = strNom2 .Item("nom3").Range.Text = strNom3 .Item("horaires1").Range.Text = strHoraires1 .Item("horaires2").Range.Text = strHoraires2 .Item("horaires3").Range.Text = strHoraires3 .Item("contacts").Range.Text = strContacts End With End With Set rst = Nothing Set doc = Nothing Set objWord = Nothing Exit_Commande595_Click: Exit Sub Err_Commande595_Click: MsgBox Err.Description Resume Exit_Commande595_Click End Sub
Partager