Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook to Excel Macro's

Status
Not open for further replies.

Mack2

Instructor
Mar 12, 2003
336
US
1. I need to create a macro to copy an attachment from an outlook email to a certain folder.

2. Then import that file into excel. The file will consist of one supplier and many parts from that supplier.

Has anyone did something like this before. I have a lot of experience with vba, just not with outlook. Any advice would be greatly appreciated.

THANKS!
 
No, I have not. I was hoping to find someone who has actually has experience with the macro's
 
Mack2,
Ouch, is that a dig on Microsoft?

Couple of questions:[ol]
[li]Where do you want the macro to run, Outlook (push), Excel (pull), other?[/li]
[li]What type of file is the attachment?[/li]
[li]Are you doing one Email at a time, or several as a batch?[/li][/ol]

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
CMP, I guess it did look like a dig, but was not intended to be :)

1. Both. One macro in outlook to copy the attachment to the c: drive. And one from excel to import the file that was copied to the c: drive

2. Comma delimited file.

3. It will be one email at a time.

THANKS!!!! for you help
 


"...I have a lot of experience with vba..."

"...I was hoping to find someone who has actually has experience with the macro's..."


???

Skip,

[glasses] [red][/red]
[tongue]
 
Have a look at the Outlook.MailItem.Attachments collection and the Outlook.Attachment.SaveAsFile method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Mack2,
Yeah, what he said. Here is a small macro that will move the attachment if the file extension is "csv" to the [tt]C:[/tt] drive.
I would then add a new toolbar to your inspector window that points to this macro.
Code:
Option Compare Text

Sub CopyCSVAttachement()
Dim insActive As Inspector
Dim attCurrent As Attachment
Set insActive = ActiveInspector
If insActive.CurrentItem.Attachments.Count > 0 Then
  For Each attCurrent In insActive.CurrentItem.Attachments
    If Right(attCurrent.FileName, 3) = "csv" Then
      attCurrent.SaveAsFile "C:\"
    End If
  Next attCurrent
End If
Set insActive = Nothing
End Sub

If the file is CSV do you really need to write a macro to import? Excel should open the CSV file by double clicking, or do you really want the macro in Outlook to open the file for you so you don't have to navigate to the [tt]C[/tt] drive to double click on it?

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thanks everyone, I will give it a try and let you know.
THANKS!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top