Error 75

Status
Not open for further replies.

Jeremy Ollenbuttel

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server 2010
Good afternoon,

I have the following code running in Outlook 2016 along with a rule to print the attachments of specific emails as they arrive in the inbox;

Code:
Sub LSPrint(Item As Outlook.MailItem)
On Error GoTo OError

'detect Temp
Dim oFS As FileSystemObject
Dim sTempFolder As String
Set oFS = New FileSystemObject
'Temporary Folder Path
sTempFolder = oFS.GetSpecialFolder(TemporaryFolder)

'creates a special temp folder
cTmpFld = sTempFolder & "\OETMP" & Format(Now, "yyyymmddhhmmss")
MkDir (cTmpFld)

'save & print
Dim oAtt As Attachment
For Each oAtt In Item.Attachments
FileName = oAtt.FileName
FullFile = cTmpFld & "\" & FileName

'save attachment
oAtt.SaveAsFile (FullFile)

'prints attachment
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(0)
Set objFolderItem = objFolder.ParseName(FullFile)
objFolderItem.InvokeVerbEx ("print")

Next oAtt

'Cleanup
If Not oFS Is Nothing Then Set oFS = Nothing
If Not objFolder Is Nothing Then Set objFolder = Nothing
If Not objFolderItem Is Nothing Then Set objFolderItem = Nothing
If Not objShell Is Nothing Then Set objShell = Nothing

OError:
If Err <> 0 Then
MsgBox Err.Number & " - " & Err.Description
Err.Clear
End If
Exit Sub

End Sub

This works fine if emails drop in one at a time, if I get multiple emails from the same sender I get the error 75
which is file or path error, I'm guessing that this is due to the temp save and print of the attachment.

Is ther a way of dealing with each email in turn to ensure the path is free before starting on the next?

Any help appreciated.

Kind regards

Jeremy
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Assuming they aren't arriving at the same split second, it should work - i wonder if it's because the macro is busy. Try splitting it into two macros - the rule hands off to the second macro. You could also try a temp folder named with the sendon time or add the time to the temp filename.

Sub LSPrint(Item As Outlook.MailItem)
newprintmacro item
end sub

Sub newprintmacro(Item As Outlook.MailItem)
'all the print code
endsub
 

Jeremy Ollenbuttel

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server 2010
Assuming they aren't arriving at the same split second, it should work - i wonder if it's because the macro is busy. Try splitting it into two macros - the rule hands off to the second macro. You could also try a temp folder named with the sendon time or add the time to the temp filename.

Sub LSPrint(Item As Outlook.MailItem)
newprintmacro item
end sub

Sub newprintmacro(Item As Outlook.MailItem)
'all the print code
endsub
Hi,
Thanks for the quick response, the emails are generated from a reporting system and can hit my inbox simultaneously some times it may generate close to 100 or so.

I'm new to vba in outlook could you help a bit further with the possibility of splitting the code into two?

Thanks
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
All you need to do is replace the name of the macro with this then test it. Hundreds at once can be a problem though, especially if the filename is identical. You could try a counter.... but outlook rules really can't handle a ton of messages at once. Using a rule to move them to a folder then have a macro watch the folder might work a little better.


Code:
Sub LSPrint(Item As Outlook.MailItem)
newprintmacro item
end sub

Sub newprintmacro(Item As Outlook.MailItem)


to add a counter, at the very top of the module, add
dim counter as long

then add this as the first line (under the sub name)
counter = counter + 1

and change the filename to

FileName = oAtt.FileName & counter
 

Jeremy Ollenbuttel

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server 2010
Hi,

I hope I understood you correctly, with the code below I still get the error but nothing prints now?

Regards

Code:
Dim counter As Long

Sub LSPrint(Item As Outlook.MailItem)
NewPrintMacro Item
counter = counter + 1

End Sub
Sub NewPrintMacro(Item As Outlook.MailItem)

On Error GoTo OError

'detect Temp
Dim oFS As FileSystemObject
Dim sTempFolder As String
Set oFS = New FileSystemObject
'Temporary Folder Path
sTempFolder = oFS.GetSpecialFolder(TemporaryFolder)

'creates a special temp folder
cTmpFld = sTempFolder & "\OETMP" & Format(Now, "yyyymmddhhmmss")
MkDir (cTmpFld)

'save & print
Dim oAtt As Attachment
For Each oAtt In Item.Attachments
FileName = oAtt.FileName & counter
FullFile = cTmpFld & "\" & FileName

'save attachment
oAtt.SaveAsFile (FullFile)

'prints attachment
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(0)
Set objFolderItem = objFolder.ParseName(FullFile)
objFolderItem.InvokeVerbEx ("print")

Next oAtt

'Cleanup
If Not oFS Is Nothing Then Set oFS = Nothing
If Not objFolder Is Nothing Then Set objFolder = Nothing
If Not objFolderItem Is Nothing Then Set objFolderItem = Nothing
If Not objShell Is Nothing Then Set objShell = Nothing

OError:
If Err <> 0 Then
MsgBox Err.Number & " - " & Err.Description
Err.Clear
End If
Exit Sub

End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Outlook 2013 All imported Mail Rules in error when imported into new profile Using Outlook 5
H Outlook 2019 Certificate error Using Outlook 2
V Date and/or time error in Outlook Form Outlook VBA and Custom Forms 0
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
E Complite error on SaveAsFile method Outlook VBA and Custom Forms 2
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
D Outlook VBA error extracting property data from GetRules collection Outlook VBA and Custom Forms 10
A Unable to save recurring Meeting to Documents folder due to error Using Outlook 2
M Compile error: User-defined type not defined Outlook VBA and Custom Forms 0
R Error when trying to forward current email item Outlook VBA and Custom Forms 7
M ERROR: None of your email accounts could send to this recipient Using Outlook 2
J OLADD.FAE Error When Exporting Contacts Using Outlook 6
C Send/receive error 80040119 Using Outlook 2
W error with the permission for the file Outlook VBA and Custom Forms 0
L Outlook 2019 MAC sync error after working for 4 hours Using Outlook 1
A Run time error 424. object required in outlook 2013 Outlook VBA and Custom Forms 10
M error code 0x8DE00006 Using Outlook 1
M Desktop Version Of Outlook Generating Error Using Outlook 4
M Send/Receive error 0x800CCC0F Using Outlook 0
T Outlook 2016 CSV Translator Import Error Using Outlook 6
ManaarZakaria I'm afraid of this issue, cause of strange error Exchange Server Administration 2
P Suppress dialog box on email check error? Using Outlook 5
vodkasoda Object could not be found Error in Outlook 2007 Outlook VBA and Custom Forms 5
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
avant-guvnor Outlook.Application now produces error Outlook VBA and Custom Forms 5
P Run Time Error 91 when linking contact to task in VBA Outlook VBA and Custom Forms 1
N Error 0x80090326 when trying to setup IMAP account on Outlook.com Using Outlook.com accounts in Outlook 1
N Saving And Deleting Outlook Attachments with Unknown Error Message Outlook VBA and Custom Forms 1
Dennis Gaudenzi Your setup couldn't be started because of an unexpected error (mapi 0x80040604) Using Outlook 14
M Outlook 2013 fails to start -- missing WindowsCodecs.dll error Using Outlook 3
Steshelter ICloud Unexpected Error Using Outlook 5
Rupert Dragwater "there was an error reading this theme" Using Outlook 3
A Error: The name cannot be matched to a name in the address list Using Outlook.com accounts in Outlook 0
S Error using AddressEntry.GetContact - need help Outlook VBA and Custom Forms 2
J Outlook - 2013 - Error msg when copying folders from Online Archives to another user's mailbox Using Outlook 0
Vijay Error in rule- Run a script Using Outlook 1
B Automation error running VB macro code Outlook VBA and Custom Forms 8
J Object Variable or With Block Not Set Error in Outlook 2016 and not Outlook 2013 Outlook VBA and Custom Forms 3
R Macro to copy email to excel - Runtime Error 91 Object Variable Not Set Outlook VBA and Custom Forms 11
Diane Poremsky The Attachment Size Exceeds the Allowable Limit Error New Slipstick.com Articles 0
Diane Poremsky RMS Error: System clock has been tampered with New Slipstick.com Articles 0
Diane Poremsky Error Opening Outlook and Control Panel's Mail Applet New Slipstick.com Articles 0
K Error: Paper Size Invalid Using Outlook 0
M Error 0x 800CCC92 Using Outlook 0
Diane Poremsky Cannot start Microsoft Office Outlook Error Message New Slipstick.com Articles 0
S Autosave attachments error using Len Outlook VBA and Custom Forms 2
C Copy email to excel runtime error 5020 Using Outlook 5
B "The properties of the message…have been changed" error Outlook VBA and Custom Forms 1
I Windows 10 - .msg files on disk show Explorer popup error Using Outlook 5
M Outlook 2010 Error: Your IMAP server closed the connection Using Outlook.com accounts in Outlook 1

Similar threads

Top