opening PowerPoint from Word

T

Tony Logan

I'm using Word 2002, and I'm wondering if it's possible to open a PowerPoint
file from Word and save the PPT file as a PDF. The user would need to be able
to select the folder the particular file was in.

I found some example coding to control PowerPoint from Word, but the example
code throws an error with the first variable declaration, which is:

Dim oPPT As PowerPoint.Application

Does anyone know if it's possible to do what I'm trying to do? Thanks.
 
S

Stephanie Krieger

Hi,

Sure -- you can do it ... the only issue that I've run
into before is that some networks restrict accessing one
application from script within another (which would not
allow the script to open PowerPoint if it wasn't already
running). If that's not an issue where you are, the
following code will work fine to provide a file picker
dialog box in Word where you user can select the file,
then to open PowerPoint if it isn't yet -- and to open
that file (and make that file your active window). I can
give you the code for converting to Acrobat -- but you
can also get it just from recording a macro while you run
an Acrobat conversion in PowerPoint. (Depending on how
you've got Acrobat integrated with PowerPoint, you might
want to do this in a couple of ways) ...

IMPORTANT: Be sure to add the PowerPoint 10.0 object to
the module containing this macro (through Tools,
References in VB Editor). Otherwise, it won't recognize
PowerPoint commands correctly.

Here's the Word code:

Sub OpenPPTFile()

Dim fd As FileDialog
Set fd = Application.FileDialog
(msoFileDialogFilePicker)
Dim vrtItem As Variant
Dim myLogo As String

With fd
.AllowMultiSelect = False

If .Show = -1 Then
For Each vrtItem In .SelectedItems
myFile = vrtItem
Next vrtItem
End If
End With
Set fd = Nothing



Set ppt1 = CreateObject("PowerPoint.Application")

ppt1.Visible = True

ppt1.Presentations.Open (myFile)
ppt1.Activate

End Sub

Hope this helps.

Best,
Stephanie Krieger
author of Microsoft Office Document Designer
email: MODD_2003 at msn dot com
blog: arouet.net
 
T

Tony Logan

Hi, Stephanie. Thanks for the code; it works well.

I tried recording a macro to convert a PowerPoint file to PDF, but for some
reason, when I access my list of macros, both the "Run" and "Step Into"
buttons are greyed out when I choose the "SaveAsPDF" macro I made, and I'm
not sure why.

I'm running Acrobat 6, PowerPoint 2002, and Windows XP. We create our PDFs
from PowerPoint by selecting File > Print (in PowerPoint), setting the
Printer Name field to "Adobe PDF," and clicking the "Print" button. Also, I
have the following Adobe PDF printer Property settings selected: "View Adobe
PDF results" and "Prompt for PDF filename" (this one to get the user to save
the PDF to the same folder where the PPT resides...don't know, but there may
be a way to do this programatically, as well).

Recording that as a PowerPoint macro results in the following code:

With ActivePresentation.PrintOptions
.RangeType = ppPrintAll
.NumberOfCopies = 1
.Collate = msoTrue
.OutputType = ppPrintOutputSlides
.PrintHiddenSlides = msoTrue
.PrintColorType = ppPrintColor
.FitToPage = msoFalse
.FrameSlides = msoFalse
.ActivePrinter = "Adobe PDF"
End With
ActivePresentation.PrintOut
End Sub

Any ideas why the "Run" and "Step Into" buttons are greyed out in my macro
list?

Thanks again.

-Tony
 
T

Tony Logan

Solved one problem: my Security setting in PPT was High; by switching it to
low, I can now run macros. For now, Stephanie, I don't need a response.
Thanks again for your earlier response.

-Tony
 

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