Recherche

Insérez un bouton de commande Contrôle ActiveX dans le document (Onglet Développeur, groupe Contrôles, bouton Outils hérités, rubrique Contrôles ActiveX).

Pour modifier le texte du bouton, cliquez sur Propriétés, puis mettez le texte plour la propriété Caption.

Alors que vous êtes toujours en mode Création, double-cliquez sur le bouton afin d'ouvrir Visual Basic. Puis collez les macros suivantes en fonction de votre type de formulaire.

 

Contrôles de contenu

Private Sub CommandButton1_Click()
Dim controle As ContentControl
Dim cont_texte
For Each controle In ActiveDocument.ContentControls
    If controle.Type <> wdContentControlCheckBox Then
    cont_texte = controle.Range
        If cont_texte = controle.PlaceholderText Then
            MsgBox "Vous devez remplir tous les champs du formulaire avant d'envoyer le fichier."
            Exit Sub
        End If
    End If
Next
Call envoi
End Sub

Sub envoi()
Dim nfichier As String, nfichier2 As String, intpos As Byte, chemin As String
Dim ol As Object, monItem As Object, mondoc
Set ol = CreateObject("outlook.application")
Set monItem = ol.CreateItem(0)
If ActiveDocument.Path = vbNullString Then
MsgBox "Sauvegardez d'abord votre fichier"
Exit Sub
End If
chemin = ActiveDocument.Path & "\"
nfichier = ActiveDocument.Name
intpos = InStrRev(nfichier, ".")
nfichier = Left(nfichier, intpos - 1)
nfichier2 = nfichier & ".pdf"
ActiveDocument.ExportAsFixedFormat outputFileName:=chemin & nfichier2, _<br>exportFormat:=wdExportFormatPDF

monItem.To = "Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser."
monItem.Subject = "objet du mail"
monItem.Body = "Bonjour" & Chr(13& Chr(13& "Je vous prie de bien vouloir trouver blabla"
Set mondoc = monItem.Attachments
mondoc.Add chemin & nfichier2
monItem.Send
Set ol = Nothing
MsgBox "le fichier a bien été transmis."
Kill nfichier2
End Sub

 

 

 

Statistiques

France 74,8% France
Canada 8,5% Canada
États-Unis d'Amérique 5,1% États-Unis d'Amérique

Total:

60

Pays
018271688
Aujourd'hui: 21
Hier: 96
Cette semaine: 754
Semaine dernière: 1.101
Ce mois: 4.485