Helmij,
In onderstaande VBA (Outlook 2016) wordt Sub Laptop aangeroepen die op haar beurt de Sub ReplyEmailTemplate aaroept.
Deze verloopt goed tot:
Set origEmail = Application.ActiveWindow.Selection.Item(1) en verschijnt de melding: "run-time error 438 object doesn t support this property or method"
Comment je deze er uit dan loopt het blok beginnend met ReplyEmail.To Stuk met een melding: "Run-time error 91 - Object variable or With block variable not Set"
Wat is er fout ?
Sub ReplyEmailTemplate(ByRef filePath As String, fileName As String)
Dim origEmail As MailItem
Dim replyEmail As MailItem
Set origEmail = Application.ActiveWindow.Selection.Item(1)
Set replyEmail = Application.CreateItemFromTemplate(filePath & fileName)
replyEmail.To = origEmail.Sender
replyEmail.CC = origEmail.CC
replyEmail.Subject = origEmail.Subject
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.Display
End Sub
Sub Laptop()
Dim filePath As String
Dim fileName As String
' In de variabele wordt het pad naar "....\....\...\Outlook\Templates\... geplaatst.
filePath = "\\....\......\...\...\........\.........\Outlook\Templates\Laptop"
' In de variabele wordt de naam van de template (*.oft) geplaatst.
fileName = "Aanvraag laptop.oft"
Call ReplyEmailTemplate(filePath, fileName)
End Sub
In onderstaande VBA (Outlook 2016) wordt Sub Laptop aangeroepen die op haar beurt de Sub ReplyEmailTemplate aaroept.
Deze verloopt goed tot:
Set origEmail = Application.ActiveWindow.Selection.Item(1) en verschijnt de melding: "run-time error 438 object doesn t support this property or method"
Comment je deze er uit dan loopt het blok beginnend met ReplyEmail.To Stuk met een melding: "Run-time error 91 - Object variable or With block variable not Set"
Wat is er fout ?
Sub ReplyEmailTemplate(ByRef filePath As String, fileName As String)
Dim origEmail As MailItem
Dim replyEmail As MailItem
Set origEmail = Application.ActiveWindow.Selection.Item(1)
Set replyEmail = Application.CreateItemFromTemplate(filePath & fileName)
replyEmail.To = origEmail.Sender
replyEmail.CC = origEmail.CC
replyEmail.Subject = origEmail.Subject
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.Display
End Sub
Sub Laptop()
Dim filePath As String
Dim fileName As String
' In de variabele wordt het pad naar "....\....\...\Outlook\Templates\... geplaatst.
filePath = "\\....\......\...\...\........\.........\Outlook\Templates\Laptop"
' In de variabele wordt de naam van de template (*.oft) geplaatst.
fileName = "Aanvraag laptop.oft"
Call ReplyEmailTemplate(filePath, fileName)
End Sub