scwebb
06-08-2016, 01:23 AM
Hi all,
I have written some macros for work that allows the user to insert product information into the body of an email. What I would like is for the macro to also add the relevant spec sheet for the product as an attachment (pdf).
I assume I need to use the "attachments.add" method but (not being much of a coder) I can't figure out exactly what to do. I have found various examples online of how to add an attachment to a new message, but I can't figure out how to modify it to add the attachment to my active message.
Currently my code looks something like this:
Public Sub test()
Dim Ins As Outlook.Inspector
Dim Document As Word.Document
Dim Word As Word.Application
Dim Selection As Word.Selection
Set Ins = Application.ActiveInspector
Set Document = Ins.WordEditor
Set Word = Document.Application
Set Selection = Word.Selection
Selection.TypeText Text:="Product"
Selection.TypeParagraph
Selection.TypeText Text:="Product Code"
Selection.TypeParagraph
Selection.TypeText Text:="Price"
Selection.TypeParagraph
Selection.TypeText Text:="Delivery"
Selection.TypeParagraph
Selection.TypeParagraph
End Sub
I would appreciate it if anyone could advise on how to use the attachments.add method with this code.
Thanks.
I have written some macros for work that allows the user to insert product information into the body of an email. What I would like is for the macro to also add the relevant spec sheet for the product as an attachment (pdf).
I assume I need to use the "attachments.add" method but (not being much of a coder) I can't figure out exactly what to do. I have found various examples online of how to add an attachment to a new message, but I can't figure out how to modify it to add the attachment to my active message.
Currently my code looks something like this:
Public Sub test()
Dim Ins As Outlook.Inspector
Dim Document As Word.Document
Dim Word As Word.Application
Dim Selection As Word.Selection
Set Ins = Application.ActiveInspector
Set Document = Ins.WordEditor
Set Word = Document.Application
Set Selection = Word.Selection
Selection.TypeText Text:="Product"
Selection.TypeParagraph
Selection.TypeText Text:="Product Code"
Selection.TypeParagraph
Selection.TypeText Text:="Price"
Selection.TypeParagraph
Selection.TypeText Text:="Delivery"
Selection.TypeParagraph
Selection.TypeParagraph
End Sub
I would appreciate it if anyone could advise on how to use the attachments.add method with this code.
Thanks.