Attachment Dialog in Macro

M

Mangus Pyke

I'm send an identical email with a different attachment to eight
groups of team managers on a monthly basis. The subject line changes
each month (to include the appropriate month) and the recipients
differ in each email. To simplify my life, I made a macro for each
client that looks like this:

Sub AcmeClient()
Set myolapp = CreateObject("Outlook.Application")
Set myitem = myolapp.CreateItem(olMailItem)
With myitem
..Recipients.Add ("Smith, Joe; Roberts, Bob")
Set tocontact = .Recipients.Add("Anderson, Joe")
tocontact.Type = olCC
..Subject = "Monthly Audit Report: " & Format(Date - 20, "mmmm yyyy")
Chr(13) & Chr(13) & "Please contact me if you have questions or need
more information."
..Importance = 2
End With
myitem.Display
Call InsertSig("Monthly")
Set myolapp = Nothing
Set myitem = Nothing
End Sub

This provides me with an email addressed to the correct people, with
the standard subject line and the appropriate month, and inserts a
signature that is composed of [a] two lines of text (i.e. call me if
you have question, etc) and my regular signature, which gets me
around the issues I had with dropping a pre-defined text and a
signature into the email (they were wiping each other out, so I would
end up with only a signature).

The only thing left that I want to do is spawn a dialog box to add the
file attachment that goes with the email, but I've had no luck in
figuring out that part. I'm used to the object model for Excel, but
I'm completely out of my element with Outlook.

Any suggestions?

MP-
 
M

Michael Bednarek

I'm send an identical email with a different attachment to eight
groups of team managers on a monthly basis. The subject line changes
each month (to include the appropriate month) and the recipients
differ in each email. To simplify my life, I made a macro for each
client that looks like this: [snip]
The only thing left that I want to do is spawn a dialog box to add the
file attachment that goes with the email, but I've had no luck in
figuring out that part. I'm used to the object model for Excel, but
I'm completely out of my element with Outlook.

Any suggestions?

If the macro knows the location of the attachment:
myItem.Attachments.Add(Source, Type, Position, DisplayName)

or by executing the menu item:
ActiveInspector.CommandBars("Menu Bar").Controls("Insert").CommandBar.Controls("&File...").Execute
or shorter (and presumably language independent):
ActiveInspector.CommandBars.FindControl(,1079).Execute

See also: <http://www.outlookcode.com/d/tips/commandbarfun.htm>.
 
M

Mangus Pyke

If the macro knows the location of the attachment:
myItem.Attachments.Add(Source, Type, Position, DisplayName)

or by executing the menu item:
ActiveInspector.CommandBars("Menu Bar").Controls("Insert").CommandBar.Controls("&File...").Execute
or shorter (and presumably language independent):
ActiveInspector.CommandBars.FindControl(,1079).Execute

Michael:

Thank you so much! I fought with this all day Thursday and Friday
trying everything I could find on the web, but to no avail!

I was completely off-target and not at all familiar with CommandBar.

Thank you for both the solution and the link so I can learn more!

MP-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top