Using Excel VBA to print a Powerpoint presentation

D

David Hookham

I'm have an Excel file supported with VBA. One of the requirements of the
code is to open a specified PowerPoint file, print it and then close the
file and exit PowerPoint. Ideally this would be largely invisible to the
user, but that's not essential.

I'm using the code below:

Sub PPTPrint(slink)
Dim PPObj As Object
Set PPObj = CreateObject("PowerPoint.application")
With PPObj
.presentations.Add
.presentations.Open Filename:=slink
.Visible = True
PPObj.ActivePresentation.PrintOptions.PrintInBackground = msoFalse
PPObj.ActivePresentation.PrintOut copies:=1
End With
End Sub

This works fine as long as slink is a qualified filename on a "normal"
filesystem, eg local hard drive or network. However, the files it needs to
open will be stored in a Public Folder within Exchange Server.

If slink is of the form "outlook:\\Public Folders\All Public
Folders\Datafiles\file.ppt" then the code fails. The error reported can
vary, but generally refers to an unfeasibly large line number in the code.

Any thoughts?
 

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