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
| Private Sub cmdImprimer_Click()
On Error GoTo GestionErreur
If lstClients.SelCount > 0 Then
Dim MyWord As Word.Application, doc As Word.Document
Dim signet As String, i As Long
'
Dim iRangeBoldStart As Integer
Dim iRangeBoldEnd As Integer
Dim iRangeIndentStart As Integer
Dim iRangeIndentEnd As Integer
'
Dim RangeBold As Word.Range
Dim RangeIndent As Word.Range
Set MyWord = New Word.Application
With MyWord
Set doc = .Documents.Open(App.Path & "\docs\mydoc.doc")
Dim myRange As Word.Range
Dim rsClients As New ADODB.Recordset
Dim rsContacts As New ADODB.Recordset
Dim rsNotes As New ADODB.Recordset
Dim iClient As Integer
Dim iContact As Integer
Dim iNote As Integer
Set myRange = doc.Content
myRange.Delete
For iClient = 0 To lstClients.SelCount - 1
If lstClients.Selected(iClient) Then
rsClients.Open "select clients.*, villes.ville from clients inner join villes on villes.id = clients.villes_id where clients.id = '" & lstClients_hid.List(iClient) & "';", frmVentesClients.connMyConn, 1, 3
Set myRange = doc.Content
myRange.Font.Name = "Verdana"
myRange.Font.Size = 8
With myRange
.Collapse wdCollapseEnd
' **************** CLIENT ****************
iRangeBoldStart = Len(doc.Content) - 1
.InsertAfter UCase(rsClients.Fields("entreprise"))
iRangeBoldEnd = Len(doc.Content) - 1
Set RangeBold = doc.Range(iRangeBoldStart, iRangeBoldEnd)
RangeBold.Font.Bold = True
RangeBold.Font.Size = 10
.InsertAfter vbCrLf
If Len(Trim(rsClients.Fields("adresse"))) > 0 Then
.InsertAfter rsClients.Fields("adresse")
End If
If Len(Trim(rsClients.Fields("ville"))) > 0 Then
.InsertAfter ", " & rsClients.Fields("ville")
End If
etc... |
Partager