Good Morning. I'm in a new contract and finally trying to implement
the above script in my current O2K installation.
I'm getting an error message, though, which hopefully is easy to fix;
plus a question re the library in References that I can't find.
The script, again, is:
************************************************** ************************************************** ************
Sub SaveAttachment()
'1. Make sure you have a reference set to IWshRuntimeLibrary,
' C:\WINDOWS\system32\wshom.ocx, in Tools, References of the VBE
' --------------------------------------------------------------------
' 2. This works without refs of 1, but you won't have
' help by IntelliSense:
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
' Use this code above if you don't have the option in 1. above.
' If 1. is available, "blank" out these 2 lines above with ' in front.
' --------------------------------------------------------------------
Dim objCurrentItem As Outlook.MailItem
Dim colAttachments As Outlook.Attachments
Dim objAttachment As Outlook.Attachment
Dim objFSO As Scripting.FileSystemObject
Dim strPath As String
Dim strFolder As String
Set objCurrentItem = Application.ActiveInspector.CurrentItem
Set colAttachments = objCurrentItem.Attachments
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPath = "(path to desktop)\Desktop\"
strFolder = "Outlook embedded graphics\"
strPath = strPath & strFolder
If Not (objFSO.FolderExists(strPath)) Then
objFSO.CreateFolder (strPath)
End If
For Each objAttachment In colAttachments
objAttachment.SaveAsFile (strPath & objAttachment.FileName)
Next
Set objAttachment = Nothing
Set colAttachments = Nothing
Set objCurrentItem = Nothing
Set objFSO = Nothing
End Sub
************************************************** ************************************************** ************
1. The part "objFSO As Scripting.FileSystemObject" gets highlighted
and the error is:
"Compile error: User-defined type not defined". Was wondering what
this meant?
2. I put the non-refs code of #2 in because I don't have the
"IWshRuntimeLibrary" as an option in this particular installation
under TOOLS REFERENCES in the VBE here at work. I tried just
browsing to and selecting the "wshom.ocx" file and that gave the
reference of "Windows Script Host Object Model" there, but I'm
doubtful that that's what is needed though thought I'd meantion it.
The wshom.ocx exists in that folder, it's just that references doesn't
list IWshRuntimeLibrary. Thinking that you might have meant
WshRuntimeLibrary I looked for that, but there's no reference to that,
either. Could it be named something else? I looked through the tons
of stuff listed, but couldn't find anything that looked similar.
Anyway, thanks for any help re this. It'd be really nice to get this
to work once and for all. Cheers.

D