PDA

View Full Version : Unknown problem with an Outlook macro...



cliffwms
06-22-2010, 06:36 AM
This macros opens the correct email with a zipped attachement, copies the zipped file to a directory and runs the GREENSHT.BAT. It does what it is supposed to do but the strange (unknown) issue is when the BAT file is run using this macro it does not function correctly (winzip opens with a blank file named GREENSHT.ZIP). When I run the batch file (by double clicking it) it works perfectly:

THE BATCH FILE:



ECHO OFF
CD I:\S3DATA~1\MEPSFLR\FLRCDR~1\BDE_RE~1\
DEL GREENSHT.ZIP
IF EXIST RY10OC~2.ZIP COPY RY10OC~2.ZIP GREENSHT.ZIP
IF EXIST RY10NO~2.ZIP COPY RY10NO~2.ZIP GREENSHT.ZIP
IF EXIST RY10DE~2.ZIP COPY RY10DE~2.ZIP GREENSHT.ZIP
IF EXIST RY10JA~2.ZIP COPY RY10JA~2.ZIP GREENSHT.ZIP
IF EXIST RY10FE~2.ZIP COPY RY10FE~2.ZIP GREENSHT.ZIP
IF EXIST RY10MA~2.ZIP COPY RY10MA~2.ZIP GREENSHT.ZIP
IF EXIST RY10AP~2.ZIP COPY RY10AP~2.ZIP GREENSHT.ZIP
IF EXIST RY10MA~2.ZIP COPY RY10MA~2.ZIP GREENSHT.ZIP
IF EXIST RY10JU~2.ZIP COPY RY10JU~2.ZIP GREENSHT.ZIP
IF EXIST RY10AU~2.ZIP COPY RY10AU~2.ZIP GREENSHT.ZIP
IF EXIST RY10SE~2.ZIP COPY RY10SE~2.ZIP GREENSHT.ZIP
START C:\PROGRA~1\WINZIP\WINZIP32.EXE GREENSHT.ZIP
EXIT


THE OUTLOOK MACRO:


Sub UnzipAttachment(Item As Outlook.MailItem)
Dim olkAttachment As Outlook.Attachment, _
objShell As Object
Set objShell = CreateObject("Wscript.Shell")
If Item.Attachments.Count > 0 Then
For Each olkAttachment In Item.Attachments
If LCase(Right(olkAttachment.FileName, 4)) = ".zip" Then
olkAttachment.SaveAsFile "I:\S3DATA~1\MEPSFLR\FLRCDR~1\BDE_RE~1\" & olkAttachment.FileName
objShell.Run "I:\S3DATA~1\MEPSFLR\FLRCDR~1\BDE_RE~1\GREENSHT.BAT" '& olkAttachment.FileName & ""
End If
Next
End If
Set olkAttachment = Nothing
Set objShell = Nothing
End Sub

Mix109497700
06-22-2010, 04:19 PM
No idea what the problem is....

Crocus Crow
06-23-2010, 02:05 AM
Try:
objShell.Run "I:\S3DATA~1\MEPSFLR\FLRCDR~1\BDE_RE~1\GREENSHT.BAT", , True
For debugging the .bat file, use ECHO ON and PAUSE before the WinZip.

cliffwms
06-23-2010, 05:10 AM
Try:
objShell.Run "I:\S3DATA~1\MEPSFLR\FLRCDR~1\BDE_RE~1\GREENSHT.BAT", , True
For debugging the .bat file, use ECHO ON and PAUSE before the WinZip.

did this until i got the batch file to work
and as I mentioned it works fine when I
run it by double clicking the bat file. I
have changed the obj.run line as you
have shown -- will wait til 0930 and see
what happens.

Either way -- I APPRECIATE YOUR HELP!!!!

cliff