Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > Computer Support > VB help _please_. Incorporating this vb code to original script?

Reply
Thread Tools

VB help _please_. Incorporating this vb code to original script?

 
 
fitwell
Guest
Posts: n/a
 
      12-06-2005
I have this working vb code in Outlook 2000:

************************************************** *****
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:\WINDOWS\Desktop\OutlookEmbeddedGraphics\" &
objAttachment.FileName)
Next

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

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




The folder in question is the above one called
"OutlookEmbeddedGraphics" on the desktop (in the
"objAttachment.SaveAsFile" line above).

The script doesn't work if the folder isn't there.

Apparently, this needs to be added to the above to get it to work:
************************************************** *****
Dim oFso as Scripting.FileSystemObject
set oFso = new Scripting.FileSystemObject
If not oFso.FolderExists(YourFolder) then
oFso.CreateFolder YourFolder
Endif
************************************************** *****


But nothing I've done works. I've tried several different ways and
have read the help file, nothing. I'm a real newbie with VB and don't
find it easy to understand. I know there are vb experts here, so
hoping someone here has run into this type of code before and will
know how to make a working integration possible so that the folder is
created on the desktop before trying to save the embedded graphics if
it doesn't exist.

[And yes, I have gone to the MS Outlook ngs re this but not only has
this not been resolved, they have the worst sort of condescending
attitude on it that I have ever come across in my 6 years of using
ngs. The Access and Excel groups don't do this at all, it's just the
Outlook ones! They don't know what it is to be a newbie and they just
make you feel really stupid into the bargain <sigh>.]

Thanks so much in advance. I'd be grateful for any help.

 
Reply With Quote
 
 
 
 
why?
Guest
Posts: n/a
 
      12-06-2005

On Tue, 06 Dec 2005 04:57:54 -0500, fitwell wrote:

There are several visual basic newsgroups, try one. There are also lots
of VB tutorials.

>I have this working vb code in Outlook 2000:


That's vb for Visual Basic or VBScript , slight difference?

>************************************************* ******
>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:\WINDOWS\Desktop\OutlookEmbeddedGraphics\" &
>objAttachment.FileName)


<snip>

>The folder in question is the above one called
>"OutlookEmbeddedGraphics" on the desktop (in the
>"objAttachment.SaveAsFile" line above).
>
>The script doesn't work if the folder isn't there.


As happens when the folder doesn't exist

You could of course set a variable to the returned error code and put in
a few lines to handle it.

You have to love these examples with no references to examples / source
code location

>Apparently, this needs to be added to the above to get it to work:
>************************************************* ******
>Dim oFso as Scripting.FileSystemObject
>set oFso = new Scripting.FileSystemObject


Looks like mixed VB / VBScript, it's been a long time , according to
the stull on the MSDN links below,

Set fso = CreateObject("Scripting.FileSystemObject")

Works in Visual Basic and VBScript


>If not oFso.FolderExists(YourFolder) then
> oFso.CreateFolder YourFolder
>Endif
>************************************************* ******


I am not going to put in an example, there are lots , search for some.


Re difference mentioned in VB / VBScript , see the MSDN link below.

>
>But nothing I've done works. I've tried several different ways and


If nothing works, try something

>have read the help file, nothing. I'm a real newbie with VB and don't
>find it easy to understand. I know there are vb experts here, so
>hoping someone here has run into this type of code before and will


Make things simple, create a new project / code only the FSO on it's own
, don't test it with the Outlook bit.

Basically write a small test to try some simple FSO things. See then
MSDN link again.

>know how to make a working integration possible so that the folder is
>created on the desktop before trying to save the embedded graphics if
>it doesn't exist.
>
>[And yes, I have gone to the MS Outlook ngs re this but not only has


It's not an OL , nor Access or even Excel issue.

Besides a VB issue you may also want to try one of the MS Scripting
newsgroups.

microsoft.public.scripting.scriptlets
http://groups.google.com/group/micro...ing.scriptlets
looks a bit empty

microsoft.public.scripting.vbscript
http://groups.google.com/group/micro...pting.vbscript

microsoft.public.scripting.wsh
http://groups.google.com/group/micro....scripting.wsh

Maybe a bit heavy duty, but it's the MSDN (developer network) manual.

Working with drives / folders.
http://msdn.microsoft.com/library/de...bjectmodel.asp

Fso basics / reference.
http://msdn.microsoft.com/library/de...stemObject.asp

Check the examples.

>this not been resolved, they have the worst sort of condescending
>attitude on it that I have ever come across in my 6 years of using
>ngs. The Access and Excel groups don't do this at all, it's just the
>Outlook ones! They don't know what it is to be a newbie and they just
>make you feel really stupid into the bargain <sigh>.]
>
>Thanks so much in advance. I'd be grateful for any help.


Me
 
Reply With Quote
 
 
 
 
Duane Arnold
Guest
Posts: n/a
 
      12-06-2005
fitwell <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> I have this working vb code in Outlook 2000:
>
> ************************************************** *****
> 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:\WINDOWS\Desktop\OutlookEmbeddedGraphics\" &
> objAttachment.FileName)
> Next
>
> Set objAttachment = Nothing
> Set colAttachments = Nothing
> Set objCurrentItem = Nothing
>
> End Sub
> ************************************************** *****
>
>
>
>
> The folder in question is the above one called
> "OutlookEmbeddedGraphics" on the desktop (in the
> "objAttachment.SaveAsFile" line above).
>
> The script doesn't work if the folder isn't there.


That would be correct.

>
> Apparently, this needs to be added to the above to get it to work:
> ************************************************** *****
> Dim oFso as Scripting.FileSystemObject
> set oFso = new Scripting.FileSystemObject
> If not oFso.FolderExists(YourFolder) then
> oFso.CreateFolder YourFolder
> Endif
> ************************************************** *****
>


Yes that would be what you would have to do. And it should be the first
thing you do before you execute any other code is to check for the
directory and if it doesn't exist, then you create the directory.


>
> But nothing I've done works. I've tried several different ways and
> have read the help file, nothing. I'm a real newbie with VB and don't
> find it easy to understand. I know there are vb experts here, so
> hoping someone here has run into this type of code before and will
> know how to make a working integration possible so that the folder is
> created on the desktop before trying to save the embedded graphics if
> it doesn't exist.


You must do some error trapping with an ON Error GOTO and display the
error message if there is one coming out. Maybe you don't have the
permission to create the directory or something like that. But since you
don't have any error trapping logic in the routine, you don't know or can
see what has happened. All you know is that it didn't work.

ON Error GoTo ErrCode

Your other program logic

ON error goto 0 ' trun it off error trapping

Exit Sub

ErrCode:

MsgBox(err.message)

END


Duane

 
Reply With Quote
 
Bonia Roseoflavus Limicola Bdellomicrovirus
Guest
Posts: n/a
 
      12-06-2005
Duane Arnold <(E-Mail Removed)> wrote:

> And just what is wrong with tucking padding into discreet places to
> improve the appearance of size in my personal endowments?


 
Reply With Quote
 
Duane Arnold
Guest
Posts: n/a
 
      12-06-2005
<What K-Mammy?>

<Did the K-Rug-Rats put kitty litter laced by rat posion in your food trying
to get rid of you K-Mammy-Dearest?>



 
Reply With Quote
 
Duane Arnold
Guest
Posts: n/a
 
      12-06-2005
<They are going to take you out and it's going to be NASTY.>


 
Reply With Quote
 
fitwell
Guest
Posts: n/a
 
      12-07-2005
On Tue, 06 Dec 2005 19:59:22 GMT, Duane Arnold <(E-Mail Removed)>
wrote:

>fitwell <(E-Mail Removed)> wrote in
>news:(E-Mail Removed) :
>
>> I have this working vb code in Outlook 2000:
>>
>> ************************************************** *****
>> 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:\WINDOWS\Desktop\OutlookEmbeddedGraphics\" &
>> objAttachment.FileName)
>> Next
>>
>> Set objAttachment = Nothing
>> Set colAttachments = Nothing
>> Set objCurrentItem = Nothing
>>
>> End Sub
>> ************************************************** *****
>>
>>
>>
>>
>> The folder in question is the above one called
>> "OutlookEmbeddedGraphics" on the desktop (in the
>> "objAttachment.SaveAsFile" line above).
>>
>> The script doesn't work if the folder isn't there.

>
>That would be correct.
>
>>
>> Apparently, this needs to be added to the above to get it to work:
>> ************************************************** *****
>> Dim oFso as Scripting.FileSystemObject
>> set oFso = new Scripting.FileSystemObject
>> If not oFso.FolderExists(YourFolder) then
>> oFso.CreateFolder YourFolder
>> Endif
>> ************************************************** *****
>>

>
>Yes that would be what you would have to do. And it should be the first
>thing you do before you execute any other code is to check for the
>directory and if it doesn't exist, then you create the directory.
>
>
>>
>> But nothing I've done works. I've tried several different ways and
>> have read the help file, nothing. I'm a real newbie with VB and don't
>> find it easy to understand. I know there are vb experts here, so
>> hoping someone here has run into this type of code before and will
>> know how to make a working integration possible so that the folder is
>> created on the desktop before trying to save the embedded graphics if
>> it doesn't exist.

>
>You must do some error trapping with an ON Error GOTO and display the
>error message if there is one coming out. Maybe you don't have the
>permission to create the directory or something like that. But since you
>don't have any error trapping logic in the routine, you don't know or can
>see what has happened. All you know is that it didn't work.
>
>ON Error GoTo ErrCode
>
>Your other program logic
>
>ON error goto 0 ' trun it off error trapping
>
>Exit Sub
>
>ErrCode:
>
>MsgBox(err.message)
>
>END
>
>
>Duane


Thanks Duane. I don't know how to do this so it's all very academic.
I've searched and searched and haven't come up with working code as
I'm not able to figure it out myself. I got just this type of help in
the MS ng invovled and they said to use the object code above so I did
after a couple hours of searching. I got nowhere and pretty fast.
<sigh>

So, I'm right back where I started from. I have no idea what all the
above really means other than in broad general terms.

Thanks much, though. I do appreciate the time and the effort. I'll
just have to keep muddling along I guess. A year on this one and
still no closer, really.

 
Reply With Quote
 
old jon
Guest
Posts: n/a
 
      12-07-2005

"fitwell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have this working vb code in Outlook 2000:
>
>

snipped for neatness
>

www.google.co.uk and type in VB+tutorials
Results 1 - 10 of about 5,280,000 for VB+tutorials.
bw..OJ


 
Reply With Quote
 
Duane Arnold
Guest
Posts: n/a
 
      12-07-2005
fitwell wrote:
> On Tue, 06 Dec 2005 19:59:22 GMT, Duane Arnold <(E-Mail Removed)>
> wrote:
>
>
>>fitwell <(E-Mail Removed)> wrote in
>>news:(E-Mail Removed) m:
>>
>>
>>>I have this working vb code in Outlook 2000:
>>>
>>>*********************************************** ********
>>>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:\WINDOWS\Desktop\OutlookEmbeddedGraphics\ " &
>>>objAttachment.FileName)
>>>Next
>>>
>>>Set objAttachment = Nothing
>>>Set colAttachments = Nothing
>>>Set objCurrentItem = Nothing
>>>
>>>End Sub
>>>*********************************************** ********
>>>
>>>
>>>
>>>
>>>The folder in question is the above one called
>>>"OutlookEmbeddedGraphics" on the desktop (in the
>>>"objAttachment.SaveAsFile" line above).
>>>
>>>The script doesn't work if the folder isn't there.

>>
>>That would be correct.
>>
>>
>>>Apparently, this needs to be added to the above to get it to work:
>>>*********************************************** ********
>>>Dim oFso as Scripting.FileSystemObject
>>>set oFso = new Scripting.FileSystemObject
>>>If not oFso.FolderExists(YourFolder) then
>>> oFso.CreateFolder YourFolder
>>>Endif
>>>*********************************************** ********
>>>

>>
>>Yes that would be what you would have to do. And it should be the first
>>thing you do before you execute any other code is to check for the
>>directory and if it doesn't exist, then you create the directory.
>>
>>
>>
>>>But nothing I've done works. I've tried several different ways and
>>>have read the help file, nothing. I'm a real newbie with VB and don't
>>>find it easy to understand. I know there are vb experts here, so
>>>hoping someone here has run into this type of code before and will
>>>know how to make a working integration possible so that the folder is
>>>created on the desktop before trying to save the embedded graphics if
>>>it doesn't exist.

>>
>>You must do some error trapping with an ON Error GOTO and display the
>>error message if there is one coming out. Maybe you don't have the
>>permission to create the directory or something like that. But since you
>>don't have any error trapping logic in the routine, you don't know or can
>>see what has happened. All you know is that it didn't work.
>>
>>ON Error GoTo ErrCode
>>
>>Your other program logic
>>
>>ON error goto 0 ' trun it off error trapping
>>
>>Exit Sub
>>
>>ErrCode:
>>
>>MsgBox(err.message)
>>
>>END
>>
>>
>>Duane

>
>
> Thanks Duane. I don't know how to do this so it's all very academic.
> I've searched and searched and haven't come up with working code as
> I'm not able to figure it out myself. I got just this type of help in
> the MS ng invovled and they said to use the object code above so I did
> after a couple hours of searching. I got nowhere and pretty fast.
> <sigh>
>
> So, I'm right back where I started from. I have no idea what all the
> above really means other than in broad general terms.
>
> Thanks much, though. I do appreciate the time and the effort. I'll
> just have to keep muddling along I guess. A year on this one and
> still no closer, really.
>


You need to find a good book on VB like teach yourself VB in 21 Days
ISBN 0-672-30715-4 it's got to be dirt cheap. There are others that
should be dirty cheap books on how to program the MS Office products.

Duane
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning struts and incorporating memory realm nathanrbn@gmail.com Java 0 12-01-2005 03:10 AM
incorporating ASP pages withing a .NET project ezelasky@hotmail.com ASP .Net 1 09-09-2005 04:03 PM
OOP help needed incorporating existing modules in class Koncept Python 1 07-01-2005 03:56 AM
incorporating other's ruby code (licensing) Ara.T.Howard Ruby 2 05-18-2005 03:34 PM
Incorporating XML feed into web page KiwiBrian HTML 3 03-08-2005 12:12 AM



Advertisments