A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Please help me understand SaveAsFile for attachments



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 18th 08, 10:15 PM posted to microsoft.public.outlook.program_vba
Ed from AZ
external usenet poster
 
Posts: 6
Default Please help me understand SaveAsFile for attachments

D'oh!!!! 8\

Thank you, Sue. It now works great!!

Ed


On Apr 18, 12:59*pm, "Sue Mosher [MVP-Outlook]"
wrote:
The problem isn't with SaveAsFile but with your file name. A file name cannot include the / characters that you're adding with strDate. Windows interprets those as part of a file path which, of course, does not exist.

--
Sue Mosher, Outlook MVP
* *Author of Microsoft Outlook 2007 Programming:
* * *Jumpstart for Power Users and Administrators
* *http://www.outlookcode.com/article.aspx?id=54

"Ed from AZ" wrote in ...



(WinXPpro, OL2003) I have a PST folder full of emails with Word
documents as attachments. *I am trying to write a macro that will open
each of these emails and save the attachments to a folder as Word
docs. *I am fairly decent with Word and Excel VBA, but not very
familiar with Outlook VBA. *I found the SaveAsFile method, but I don't
quite understand how it works. *I'm trying to use it in the following
code, but it errors out:


x = objDestFolder.Items.Count
For cntI = 1 To x
*Set objItem = objDestFolder.Items(cntI)


*y = objItem.Attachments.Count
*For cntA = 1 To y
* *Set objAtt = objItem.Attachments(cntA)
* *strDoc = Left(objAtt.DisplayName, Len(objAtt.DisplayName) - 4)
* *strDate = Format(objItem.CreationTime, "mm/dd/yy")
* *strFile = strPath & strDoc & "_(" & strDate & ").doc"
* *objAtt.SaveAsFile strFile * ERROR HERE
*Next cntA
Next cntI


I can get to the folder, the email, and the attachment. *All strings
are fine. *The objAtt.SaveAsFile line, though, errors with
-209256445: Cannot save the attachment. Path does not exist. Make sure
the path is correct.


Any help setting this straight is appreciated.


Ed- Hide quoted text -


- Show quoted text -


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime error when using SaveAsFile method to save Outlook attachm confused2 Outlook and VBA 7 September 1st 08 07:29 AM
How to understand header information on OE 6 DavidJ726 Outlook Express 4 December 12th 07 11:36 PM
Cannot understand Igor Fracellio Outlook Express 2 December 3rd 06 11:35 PM
SaveAsFile, RTF and embedded images Rohan Salt Outlook and VBA 0 November 30th 06 06:08 AM
SaveAsFile - save as subject line instead of DisplayName iamjbunni Outlook and VBA 1 April 30th 06 08:54 AM


All times are GMT +1. The time now is 11:40 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.