Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Extracting attached files from outlook

I can create an e-mail with VBA code. But is it possible to get some code
that will go to a particular shared folder in outlook and then go through
each mail and open the attached file and copy a range of data? To then move
onto another folder and do the same.
Or would it be easier to get the code to save the attached files to a folder
and then extract the data?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Extracting attached files from outlook

I did a similar thing recently, and because of the problems, I went for a 2
stage approach.

Stage 1, go through the shared folder and output attachments to a windows
folder.
Stage 2, process the windows folder file by file.

I have a workbook handy that does the first part, but it is a bit too much
code to post here. Drop me your email address if you want a copy.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"cjneth" wrote in message
...
I can create an e-mail with VBA code. But is it possible to get some code
that will go to a particular shared folder in outlook and then go through
each mail and open the attached file and copy a range of data? To then

move
onto another folder and do the same.
Or would it be easier to get the code to save the attached files to a

folder
and then extract the data?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Extracting attached files from outlook


What I did was for InBox folder, you can modify the code for
sharedfolder.
I could not find a way to open the attachment w/o saving it. I save it
in a temp folder, when done delete it and move to next.
Below is code I used, cut short so as to show method I used.

Sub LookOut()
Dim olApp As Outlook.Application
Dim objNameSpace As Outlook.Namespace
Dim myFol As Outlook.MAPIFolder, myAtt As Attachment
Dim myFile As String, myWb As Workbook

Set olApp = CreateObject("Outlook.Application")
Set objNameSpace = olApp.GetNamespace("MAPI")
Set myFol = objNameSpace.GetDefaultFolder(olFolderInbox)

For Each Item In myFol.Items
If Item.Attachments.Count 0 Then
n = Item.Attachments.Count
For j = 1 To n
If InStr(1, Item.Attachments.Item(j).Filename, ".xls",
vbTextCompare) 0 Then
Set myAtt = Item.Attachments.Item(j)
myFile = "C:\Temp\MyFile.xls"
myAtt.SaveAsFile myFile
Set myWb = Workbooks.Open(myFile)
With myWb
'your code to extract data
.Close (False)
End With
myWb.Close False
Kill myFile
End If
Next j
End If
Next Item
End Sub

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using attached excel- files from webmail Joke Excel Discussion (Misc queries) 1 October 28th 08 12:56 PM
cannot open excel files attached to outlook Ohio Ray Excel Discussion (Misc queries) 1 July 27th 05 01:51 PM
Excell Files attached to emails are suddenly not readable today. . Debbie Excel Discussion (Misc queries) 1 January 11th 05 06:34 PM
attached file using outlook MD Excel Programming 0 October 27th 04 08:59 AM
Excel 2002 files attached to Outlook 2002 EMails change size AJStadlin Excel Programming 1 October 15th 03 12:12 AM


All times are GMT +1. The time now is 10:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"