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
| Option Compare Database
Public Sub InsererDansWord()
'On Error Resume Next
' Déclaration des variables et des constantes
Dim strtype As String
Dim objWord As New Word.Application
Dim strNomPrenom As String
Dim strPrestation As String
Dim strDate As String
Dim sSQL1 As String
strNomPrenom = Forms.Commandes.Titre & " " & Forms.Commandes.Nomclient & " " & Forms.Commandes.Prenomclient
strPrestation = Forms.Commandes.Factures.Form.RqTotalprestsubform.Form.IDproduittransition & " " & Forms.Commandes.Factures.Form.RqTotalprestsubform.Form.Memoproduit
strDate = Forms.Commandes.Factures.Form.RqTotalprestsubform.Form.Dateprestation & " " & Forms.Commandes.Factures.Form.RqTotalprestsubform.Form.Heureprestation
strtype = Forms.Commandes.Factures.Form.RqTotalprestsubform.Form.IDtypetransition
sSQL1 = "SELECT Hotels.Nomhotel FROM Hotels WHERE Hotels.IDhotel = Forms.Commandes.HotelPrague"
' ---------- Début de la sélection
Select Case strtype
Case 1
With objWord
.Documents.Add Template:=CurrentProject.Path & "\vouchervisitereguliere.doc", NewTemplate:=False, DocumentType:=0
.ActiveDocument.Bookmarks("Name").Range.Text = strNomPrenom
.ActiveDocument.Bookmarks("Prestation").Range.Text = strPrestation
.ActiveDocument.Bookmarks("Date").Range.Text = strDate
.ActiveDocument.Bookmarks("Numpax").Range.Text = Forms.Commandes.Numpax
.ActiveDocument.Bookmarks("Numresa").Range.Text = Forms.Commandes.Factures.Form.IDfacture
End With
Case 2, 6
With objWord
.Documents.Add Template:=CurrentProject.Path & "\vouchervisiteprivee.doc", NewTemplate:=False, DocumentType:=0
.ActiveDocument.Bookmarks("Name").Range.Text = strNomPrenom
.ActiveDocument.Bookmarks("Prestation").Range.Text = strPrestation
.ActiveDocument.Bookmarks("Date").Range.Text = strDate
.ActiveDocument.Bookmarks("Numpax").Range.Text = Forms.Commandes.Numpax
.ActiveDocument.Bookmarks("Numresa").Range.Text = Forms.Commandes.Factures.Form.IDfacture
.ActiveDocument.Bookmarks("Nomguide").Range.Text = Forms.Commandes.Factures.Form.RqTotalprestsubform.Form.Guidetransition
End With
Case 3
With objWord
.Documents.Add Template:=CurrentProject.Path & "\vouchertransfert.doc", NewTemplate:=False, DocumentType:=0
.ActiveDocument.Bookmarks("Name").Range.Text = strNomPrenom
.ActiveDocument.Bookmarks("Prestation").Range.Text = strPrestation
.ActiveDocument.Bookmarks("Date").Range.Text = strDate
.ActiveDocument.Bookmarks("Numpax").Range.Text = Forms.Commandes.Numpax
.ActiveDocument.Bookmarks("Numresa").Range.Text = Forms.Commandes.Factures.Form.IDfacture
.ActiveDocument.Bookmarks("Nomhotel").Range.Text = sSQL1
End With
Case Else
With objWord
.Documents.Add Template:=CurrentProject.Path & "\voucherautre.doc", NewTemplate:=False, DocumentType:=0
.ActiveDocument.Bookmarks("Name").Range.Text = strNomPrenom
.ActiveDocument.Bookmarks("Prestation").Range.Text = strPrestation
.ActiveDocument.Bookmarks("Date").Range.Text = strDate
.ActiveDocument.Bookmarks("Numpax").Range.Text = Forms.Commandes.Numpax
.ActiveDocument.Bookmarks("Numresa").Range.Text = Forms.Commandes.Factures.Form.IDfacture
End With
'affichage en plein écran
.WindowState = wdWindowStateMaximize
'lance la boite de dialogue d'enregistrement du document
With .Dialogs.Item(wdDialogFileSaveAs)
.Name = "Z:\Clients - Propositions AGP\"
'si on clique sur enregistrer... sinon...
If .Show = -1 Then
MsgBox "Document enregistré"
Else
objWord.Quit savechanges:=False
MsgBox "vous avez annulé l'enregistrement!"
End If
End With
'en cas de modification de l'enregistrement, on sauvegarde
If Dirty = True Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If
'Libération de l'objet
Set objWord = Nothing
End Select |
Partager