Bonjour,
Je souhaite créer un script VBA sur une boite mail qui reçoit des validations de demandes par mail avec une pièce jointe au format infopath. Je souhaite qu'elles soient imprimées automatiquement à leur réception.
J'ai écrit un code mais le résultat n'est pas concluant...
La pièce jointe est bien sauvegardée sur le disque, infopath s'ouvre, le document est chargée, mais l'impression coince "A Runtime Error has occurred"
et il sort une page blanche sur l'imprimante avec un joli message :"ERROR: syntaxerror OFFENDING COMMAND: etc..."
Voici le code que j'ai écris :
Quelqu'un aurait-il une idée du problème?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Private Sub Application_NewMailEx(ByVal EntryIDCollection As String) Dim MyMail, myAttachments As Object Dim AppIP As New infoPath.Application Dim strFileName As String Set MyMail = Application.Session.GetItemFromID(EntryIDCollection) Set myAttachments = MyMail.Attachments MsgBox (myAttachments(1).DisplayName) 'ok strFileName = myAttachments(1).FileName myAttachments(1).SaveAsFile ("C:\" & strFileName) 'ouverture et impression de formulaire infopath AppIP.XDocuments.Open ("C:\" & strFileName) AppIP.XDocuments(0).PrintOut AppIP.Quit Set MyMail = Nothing Set myAttachments = Nothing Set AppIP = Nothing End Sub
Je vous remercie.
Partager