Erreur " Erreur lors de l'ouverture de la fenêtre de rédaction... "

17chrono.ods (135.43 Ko)

Bonjour à tous,

Je me permets de poster ce message afin d'obtenir un petit peu d'aide si possible

J'ai essayer de créer un module permettant d'envoyer un mail automatiquement avec un contenu depuis Thunderbird. Je ne l'ai pas inventé mais adapté d'un code VBA trouvé sur le net.

1) Lors du "cliquage" sur mon bouton qui doit générer l'envoi de mon mail, j'ai un message d'erreur qui apparaît "Erreur lors de l'ouverture de rédaction des messages....". Le même code identique fonctionne lorsque je lis mon bouton avec le fichier d'origine d'où j'ai récupéré le code.

Y-aurait il une âme charitable pour m'aider à me dépatouiller de ce petit problème ? Je vous mets ci-dessous le code et vous joins mon fichier avec 2/3 lignes de complété.

Sub EnvoiMailRelance()

Dim Rep As Integer
        yourmsgbox = MsgBox("Souhaitez-vous envoyer le mail ? ", vbOKCancel + vbExclamation, "Demande de confirmation")
        If yourmsgbox = vbCancel Then
        Exit Sub
        End If
        If yourmsgbox = vbOK Then
        End If
Dim sNomFic As String, sRep As String
Dim tTo As String, tCC As String, tBCC As String, tSujet As String, fichier As String
Dim objShell
Set objShell = CreateObject("WScript.Shell")

sRep = ThisWorkbook.Path 'WshShell.SpecialFolders("Desktop")
sNomFic = "Demande_Intervention.pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sRep & "\" & sNomFic, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

strHtml = "Bonjour, </font></BR>"
strHtml = strHtml & "<BR>" & _
"La demande de " & " " & [C3] & " " & "est toujours en attente de traitement depuis le" & " " & [B3] & ". </font></BR>"
strHtml = strHtml & "<BR>" & _
"Merci de bien vouloir la traiter au plus vite. </font></BR>"
strHtml = strHtml & "<BR>" & _
"<font color=black>Bien cordialement.</font>" & "<BR><BR>"
strHtml = strHtml & "<BR>" & _
"<font color=blue>Le secrétariat de la DRH </font>" & "<BR>"
strHtml = strHtml & "<BR><BR>"
strHtml = strHtml & ""

tTo = [H3]
tCC = [I3]
tSujet = [G3] & " " & "Demande en attente" & " " & [C3]
fichier = sRep & "\" & sNomFic

objShell.Exec ("%ProgramFiles%\Mozilla Thunderbird\thunderbird.exe -compose" & _
  " preselectid='id1'" & _
  ",to='" & tTo & "'" & _
  ",cc='" & tCC & "'" & _
  ",bcc='" & tBCC & "'" & _
  ",newsgroups=''" & _
  ",subject='" & tSujet & "'" & _
  ",body='" & strHtml & "'" & _
  ",attachment='" & fichier & "'" & _
  ",bodyislink='false'" & _
  ",type='0'" & _
  ",format='1'" & _
  ",originalMsg=''" & _
  "")
  Application.Wait (Now + TimeValue("0:00:03"))
  SendKeys "^{ENTER}", True
Set objShell = Nothing
End Sub

La partie suivante dépendait du fichier d'origine mais je ne suis pas sûre de pouvoir l'enlever pour que ma macro fonctionne :

sRep = ThisWorkbook.Path 'WshShell.SpecialFolders("Desktop")
sNomFic = "Demande_Intervention.pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sRep & "\" & sNomFic, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

2) Est-il possible de modifier le bouton créée pour y insérer plutôt un lien hypertexte où l'agent devra cliquer pour envoyer le mail ?

3) Mes collègues devront utiliser ce fichier avec libre office. Dois-je donc le modifier pour qu'il soit utilisable par tous ?

Merci d'avance à ceux qui pourront m'apporter un petit peu d'aide

bonjour,

essaie ceci, adapté d'après la document thunderbird. (non testé, car je n'ai pas thunderbird).

Sub EnvoiMailRelance()

    Dim Rep As Integer
    yourmsgbox = MsgBox("Souhaitez-vous envoyer le mail ? ", vbOKCancel + vbExclamation, "Demande de confirmation")
    If yourmsgbox = vbCancel Then
        Exit Sub
    End If

    Dim tTo As String, tCC As String, tBCC As String, tSujet As String, fichier As String
    Dim objShell
    Set objShell = CreateObject("WScript.Shell")

    strHtml = "Bonjour, </font></BR>"
    strHtml = strHtml & "<BR>" & _
    "La demande de " & " " & [C3] & " " & "est toujours en attente de traitement depuis le" & " " & [B3] & ". </font></BR>"
    strHtml = strHtml & "<BR>" & _
    "Merci de bien vouloir la traiter au plus vite. </font></BR>"
    strHtml = strHtml & "<BR>" & _
    "<font color=black>Bien cordialement.</font>" & "<BR><BR>"
    strHtml = strHtml & "<BR>" & _
    "<font color=blue>Le secrétariat de la DRH </font>" & "<BR>"
    strHtml = strHtml & "<BR><BR>"
    strHtml = strHtml & ""

    tTo = [H3]
    tCC = [I3]
    tSujet = [G3] & " " & "Demande en attente" & " " & [C3]

    objShell.Exec ("%ProgramFiles%\Mozilla Thunderbird\thunderbird.exe -compose" & _
    " preselectid='id1'" & _
    ",to='" & tTo & "'" & _
    ",cc='" & tCC & "'" & _
    ",bcc='" & tBCC & "'" & _
    ",subject='" & tSujet & "'" & _
    ",body='" & strHtml & "'" & _
    ",format='1'" & _
    "")
    Application.Wait (Now + TimeValue("0:00:03"))
    SendKeys "^{ENTER}", True
    Set objShell = Nothing
End Sub

par contre, je n'ai pas compris où tu veux mettre un bouton avec un lien (dans le fichier ods ou dans le mail envoyé)

pour ce qui est de libreoffice, vba est supporté de manière limitée, il faudra donc tester pour voir ce qui passe et ce qui ne passe pas et donc que ta demande aurait plutôt sa place dans un forum libreoffice ou dans la partie libreoffice de ce forum (calc, si j'ai bien compris)

Bonjour H2so4,

Déjà merci pour ton retour.

Pour le code que tu m'as corrigé. En effet ça fonctionne super par contre et j'ai oublié de la préciser, il faut que cette macro puisse s'exécuter sur chaque lignes du tableau et pas seulement la 1ère.

Pour ma 2ème question, c'était savoir si on pouvait transformer le bouton en lien intitulé" Envoyer un mail" pour que la macro s'effectue sur chaque ligne souhaitée individuellement.

Pour la 3ème, ok j'ai bien compris qu'il est possible que cela ne fonctionne pas correctement. J'irais lorsque je serais satisfaite du rendu sur excel faire un tour sur un forum libre office.

En tout cas merci

21chrono.ods (135.14 Ko)

bonjour,

2 macros, une pour l'envoi pour chaque ligne, une pour l'envoi pour les lignes sélectionnées

Sub EnvoiMailRelance()
    'envoi message pour chaque ligne
    Dim Rep As Integer
    yourmsgbox = MsgBox("Souhaitez-vous envoyer les mails ? ", vbOKCancel + vbExclamation, "Demande de confirmation")
    If yourmsgbox = vbCancel Then
        Exit Sub
    End If

    Dim tTo As String, tCC As String, tBCC As String, tSujet As String, fichier As String, objshell As Object
    Set objshell = CreateObject("WScript.Shell")
    dl = Cells(Rows.Count, 2).End(xlUp).Row
    For i = 3 To dl
        envoimail objshell, i
    Next i
    Set objshell = Nothing
End Sub

Sub EnvoiMailRelanceselection()
    'envoi message pour les lignes sélectionnées par CTRL-CLICK GAUCHE
    Dim Rep As Integer
    yourmsgbox = MsgBox("Souhaitez-vous envoyer les mails aux personnes que vous avez sélectionnées avec CTRL-CLICK gauche)? ", vbOKCancel + vbExclamation, "Demande de confirmation")
    If yourmsgbox = vbCancel Then
        Exit Sub
    End If

    Dim tTo As String, tCC As String, tBCC As String, tSujet As String, fichier As String, objshell As Object
    Set objshell = CreateObject("WScript.Shell")
    For Each i In Selection.Rows
        envoimail objshell, i.Row
    Next i
    Set objshell = Nothing
End Sub

Private Sub envoimail(objshell As Object, i)
    ' composition et envoi d'un mail thunderbird avec les infos de la ligne i via l'objet objshell
    If InStr(Cells(i, "H"), "@") > 0 Then 'verifie que l'on a bien une adresse mail pour cette ligne
        strHtml = "Bonjour, </font></BR>"
        strHtml = strHtml & "<BR>" & _
        "La demande de " & " " & Cells(i, "C") & " " & "est toujours en attente de traitement depuis le" & " " & Cells(i, "B") & ". </font></BR>"
        strHtml = strHtml & "<BR>" & _
        "Merci de bien vouloir la traiter au plus vite. </font></BR>"
        strHtml = strHtml & "<BR>" & _
        "<font color=black>Bien cordialement.</font>" & "<BR><BR>"
        strHtml = strHtml & "<BR>" & _
        "<font color=blue>Le secrétariat de la DRH </font>" & "<BR>"
        strHtml = strHtml & "<BR><BR>"
        strHtml = strHtml & ""

        tTo = Cells(i, "H")
        tCC = Cells(i, "I")
        tSujet = Cells(i, "G") & " " & "Demande en attente" & " " & Cells(i, "C")

        objshell.Exec ("%ProgramFiles%\Mozilla Thunderbird\thunderbird.exe -compose" & _
        " preselectid='id1'" & ",to='" & tTo & "'" & ",cc='" & tCC & "'" & ",bcc='" & tBCC & "'" & ",subject='" & tSujet & "'" & ",body='" & strHtml & "'" & ",format='1'")
        Application.Wait (Now + TimeValue("0:00:03"))
        SendKeys "^{ENTER}", True
    End If
End Sub

Super !! Merci @h2so4 pour la version Excel

Pour transposer sur libre office, j'ai trouvé une astuce : mettre le code suivant au début de ma macro

Option VBASupport 1

Je vais maintenant tester sur libre office si j'ai le bon résultat

En tout cas un grand merci

Rechercher des sujets similaires à "erreur lors ouverture fenetre redaction"