Do I need to dl the library(??); how to fix error message?

  • Thread starter StargateFanFromWork
  • Start date


The script involved is this one, a very slightly modified version of the one
kindly provided by Ken Slovak:
Sub SaveEmbeddedGraphics()

'1. Make sure you have a reference set to IWshRuntimeLibrary,
' C:\WINDOWS\system32\wshom.ocx, in Tools, References of the VBE (Ken
' --------------------------------------------------------------------
' 2. This works without refs of 1, but you won't have
' help by IntelliSense: (Michael Bauer)
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. (me,
is this correct?)
' --------------------------------------------------------------------

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)

Set objAttachment = Nothing
Set colAttachments = Nothing
Set objCurrentItem = Nothing
Set objFSO = Nothing
End Sub
1. In the original message, I'm advised to:

"Make sure you have a reference set to IWshRuntimeLibrary
(C:\WINDOWS\system32\wshom.ocx) in Tools, References"

I don't have this listed in TOOLS > REFERENCES of the VBE (or even a
WshRuntimeLibrary). I browsed to the wshom.ocx listed above and selected it
just in case that might do the trick and now I have a listing called
"Windows Script Host Object Model" in References. But don't know if that
overcomes the lack of a IWshRuntimeLibrary or WshRuntimeLibrary.

2. So bottom line is that the above macro still doesn't work. Don't know
if lack of this library above is what is causing problems. What does happen
when I invoke the macro is that it enters the VBE and gives the following
error message:

"Compile error:
User-defined type not defined"

and "objFSO As Scripting.FileSystemObject" is then highlighted in yellow.

Can someone pls advise how this might be fixed? Much appreciated. Thanks.

Ken Slovak - [MVP - Outlook]

Sounds like I gave you a reference to the wrong library. Try using Scripting
for the FileSystemObject and early binding (Intellisense). That's
\Systeme32\Scrrun.dll. Use that without Michael's Object declaration for fso
and his set line.


Ken Slovak - said:
Sounds like I gave you a reference to the wrong library. Try using
Scripting for the FileSystemObject and early binding (Intellisense).
That's \Systeme32\Scrrun.dll. Use that without Michael's Object
declaration for fso and his set line.

Hi, Ken, thanks.

I might be grossly misinterpreting the above but if I'm to deduce correctly,
that I search for "Scripting for the FileSystemObject and early binding
(Intellisense)" in the references or something close to this (?). The items
in References that start with "script" are these:

scripto 1.0 Type Library
ScriptPW 1.0 Type Library
ScriptSubSys 1.0 Type Library

Or do I just browse to that "scrrun.dll" file (found in "scrrun.dll") or is
there something other than "script"-something? I looked under the i's for
"intellisense" but nothing there. Sorry to be such a noob re this but this
is all new to me <lol>.

Cheers. :blush:D

Ken Slovak - [MVP - Outlook]

Windows Scripting runtime is scrrun.dll. Use that one as the reference in
Tools, References. Then in the code use Dim fso As
Scripting.FileSystemObject and you will see that as you space after As one
of the choices is now Scripting.

Early binding means if you type Scripting. Intellisense opens and lists the
members of Scripting. Late binding is when you declare a variable as Object
or Variant or don't use an As clause. Then you have no intellisense.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question