Problems printing using ExecWB

D

DanAdams

*Situation*: I have a VBA macro in Outlook that should save all email
attachments of messages in a specific mail folder to a directory on the
disk, then open and print each file using ExecWB. It is important that
each file is printed *without confirmation*, sinec there will commonly
be several hundred attachment files to be printed,

*Problem*: The files are saved to disk fine, but I get an error from
the code that should print the attachments.

*Error message*: 'dialogArguments.__IE_PrintType' is null or not an
object

*Full code*:

I have highlighted in red the apparently troublesome piece of code.

<CODE>
Sub ReceiptPrint()
Dim oApp As Application
Dim oNS As NameSpace
Dim oMsg As Object
Dim oAttachments As Outlook.Attachments
Dim strControl
Dim filenameAndPath

Set oApp = New Outlook.Application
Set oNS = oApp.GetNamespace("MAPI")
Set oFolder = oNS.GetDefaultFolder(olFolderInbox)
strControl = 0
filenameAndPath = ""

Dim folder As String
folder = InputBox("Enter reporting date (eg 29-09-05)", "Enter Date
Name")
MkDir "P:\Volume Licensing Operations Team\Monthly Orders\Microsoft
Reporting\MS Receipts\" & folder

For Each oMsg In oFolder.Items
With oMsg
If .SenderEmailAddress = "(e-mail address removed)" Then
strControl = strControl + 1
filenameAndPath = "P:\Volume Licensing Operations
Team\Monthly Orders\Microsoft Reporting\MS Receipts\" & folder & "\" &
folder & "-" & "receipt" & strControl & ".htm"
oMsg.Attachments.Item(1).SaveAsFile filenameAndPath
PrintReceipt (filenameAndPath)
End If
End With
Next

MsgBox "All receipts have now been saved to P:\Volume Licensing
Operations Team\Monthly Orders\Microsoft Reporting\MS Receipts. Macro
will atempt to print these now."

End Sub


Sub PrintReceipt(fFullPath As String)

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.Navigate ("file:///" & fFullPath)

IE.ExecWB 6, 2

IE.Quit

Set IE = Nothing

End Sub
</CODE>

Can anyone help?

Many Thanks

Dan
 

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

Top