Function attestation(wFicPublipostage) As Integer
If Application.CountA(Range("A2:A600")) = 0 Then
MsgBox "Vous devez sélectionner un produit par un OK dans la colonne A Edit " 'la plage est vide
Else
Dim WordApp As Object, WordDoc As Object
'Ouvrir Word
Set WordApp = CreateObject("Word.Application")
With WordApp
Set WordDoc = .Documents.Open(ThisWorkbook.Path & "\" & wFicPublipostage) 'Ajout GVS
With WordDoc.MailMerge
.MainDocumentType = 0 'wdFormLetters
.Destination = 1 'wdSendToPrinter
.OpenDataSource Name:=ThisWorkbook.FullName, _
ReadOnly:=True, AddToRecentFiles:=False, LinkToSource:=False, _
SQLStatement:="SELECT * FROM [PubliPost$] WHERE Edit = 'ok'"
.Execute
End With
.activedocument.Close False
.Quit
End With
'Fermez le document Word, pas besoin d'enregistrer les modifications.
Set WordApp = Nothing
End If
End Function