View Single Post
  #3  
Old March 9th 07, 02:51 PM posted to microsoft.public.outlook.program_vba
StargateFanFromWork
external usenet poster
 
Posts: 39
Default How to have Outlook create folder if folder is not present?

"Ken Slovak - [MVP - Outlook]" wrote in message
...
FileSystemObject. FolderExists(FolderSpec As String) As Boolean

If it doesn't exist then use FileSystemObject.CreateFolder(Path As String)
As Folder


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"StargateFan" wrote in message
...
This macro is missing code to create the folder, if the folder
"Outlook embedded graphics" isn't present.

What does this need to check for this folder, pls, and to create it if
it isn't there?


************************************************** **************************
********
Sub SaveAttachment()
Dim objCurrentItem As Outlook.MailItem
Dim colAttachments As Outlook.Attachments
Dim objAttachment As Outlook.Attachment

Set objCurrentItem = Application.ActiveInspector.CurrentItem
Set colAttachments = objCurrentItem.Attachments
Set strFolderpath = CreateObject("WScript.Shell")

For Each objAttachment In colAttachments
objAttachment.SaveAsFile ("C:\Documents and
Settings\Compaq_Administrator\Desktop\Outlook embedded graphics\" &
objAttachment.FileName)
Next

Set objAttachment = Nothing
Set colAttachments = Nothing
Set objCurrentItem = Nothing

End Sub

************************************************** **************************
********

Thanks! D



Hi, where would I put that in, pls? I didn't write the original script
above, btw [it's like Chinese to me, except that I'm able to figure out
where to change the folder path's name because that's rather obvious]), but
I took the plunge and put the first line of code you mention in what seemed
to me the most logical spot but I get this error:

"Compile error:

Expected: list separator or )"

You'll probably think it's stupid where I've put it in the code below but I
have no idea where it would go, I'm sorry to say.

************************************************** **************************
********
Sub SaveAttachment()
Dim objCurrentItem As Outlook.MailItem
Dim colAttachments As Outlook.Attachments
Dim objAttachment As Outlook.Attachment

Set objCurrentItem = Application.ActiveInspector.CurrentItem
Set colAttachments = objCurrentItem.Attachments
Set strFolderpath = CreateObject("WScript.Shell")

FileSystemObject. FolderExists(FolderSpec As String) As Boolean

For Each objAttachment In colAttachments
objAttachment.SaveAsFile ("C:\Documents and
Settings\Compaq_Administrator\Desktop\Outlook embedded graphics\" &
objAttachment.FileName)
Next

Set objAttachment = Nothing
Set colAttachments = Nothing
Set objCurrentItem = Nothing

End Sub
************************************************** **************************
********

Thanks in advance for any further help.

Cheers. D


Ads
 

Northern Rock - Personal Loans - Web Advertising - Car Insurance - Electricity