Save PPT from Word

X

xantara

Hello-

Part of a macro I'm trying to create for Word takes the active
document and sends it to PowerPoint, via ActiveDocument.PresentIt.
After it is imported into Powerpoint, I would like it to be saved in
the My Documents Folder as temp.ppt. However, despite many attempts
with various methods I keep getting an error. What would be the best
way to do this?

Here's one thing I've tried:

ActiveDocument.PresentIt

With PowerPoint
.SaveAs FileName:="C:\Documents and Settings\admin\My Documents
\temp.ppt"
End With

Any help would be much appreciated. Thank you!
 
J

Jonathan West

Hello-

Part of a macro I'm trying to create for Word takes the active
document and sends it to PowerPoint, via ActiveDocument.PresentIt.
After it is imported into Powerpoint, I would like it to be saved in
the My Documents Folder as temp.ppt. However, despite many attempts
with various methods I keep getting an error. What would be the best
way to do this?

Here's one thing I've tried:

ActiveDocument.PresentIt

With PowerPoint
.SaveAs FileName:="C:\Documents and Settings\admin\My Documents
\temp.ppt"
End With

Any help would be much appreciated. Thank you!

This article should poinmt you in the right direction

Control PowerPoint from Word
http://www.word.mvps.org/FAQs/InterDev/ControlPPTFromWord.htm
 
H

Helmut Weber

Hi,

the method of the following code is called "late binding",
as "early binding" doesn't work with vista here and now,
see: http://word.mvps.org/fAQs/InterDev/EarlyvsLateBinding.htm

Sub Test5a()
Dim oPpt As Object
ActiveDocument.PresentIt
Set oPpt = GetObject(, "Powerpoint.application")
With oPpt
.Presentations(1).SaveAs "c:\test\temp.ppt"
End With
oPpt.Quit
Set oPpt = Nothing
End Sub

Be aware, there are complications if there is already
a powerpoint presentation open. In that case,

With oPpt
.Presentations(.Presentations.Count).SaveAs "c:\test\temp.ppt"
End With

might be helpful. Then you got to decide,
whether powerpoint should be closed or not.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
X

xantara

Thank you for your response, but I have read that article, and it
deals with new presentations, not one that is currently open. I've
tried using some of the code on that page, but I still get errors when
saving.
 
J

Jonathan West

Thank you for your response, but I have read that article, and it
deals with new presentations, not one that is currently open. I've
tried using some of the code on that page, but I still get errors when
saving.


Instead of this line

Set oPres = .Presentations.Add(WithWindow:=msoTrue)

use this

Set oPres = .ActivePresentation

Now you have an object variable oPres pointing to the presentation most
recently worked on in PPT, which will almost certainly be the one exported
from Word.
 
X

xantara

Hi,

the method of the following code is called "late binding",
as "early binding" doesn't work with vista here and now,
see:http://word.mvps.org/fAQs/InterDev/EarlyvsLateBinding.htm

Sub Test5a()
Dim oPpt As Object
ActiveDocument.PresentIt
Set oPpt = GetObject(, "Powerpoint.application")
With oPpt
     .Presentations(1).SaveAs "c:\test\temp.ppt"
End With
oPpt.Quit
Set oPpt = Nothing
End Sub

Be aware, there are complications if there is already
a powerpoint presentation open. In that case,

With oPpt
     .Presentations(.Presentations.Count).SaveAs "c:\test\temp.ppt"
End With

might be helpful. Then you got to decide,
whether powerpoint should be closed or not.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Helmut- Your code almost works, except I get an error at this line:

Set oPpt = GetObject(, "Powerpoint.application")

Gives a runtime error 429, and says that ActiveX cannot create the
object. If I close the error and run the macro again, it works
(sorta), opening the document again in PPT, saving the first version
that was opened.
 
H

Helmut Weber

Hi,

Jonathan's .ActivePresentation
seems to be the best solution.

As far as runtime error 429 is concerned,
sorry, I don't know.

I get that error as well on several machines,
on others the macro runs as expected.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
X

xantara

Thank you both for your help, with your suggestions I was able to get
the Macro to work. Here's what I ended up with:

Dim oDoc As Document
Dim oPPT As PowerPoint.Application
Dim PPTWasNotRunning As Boolean
Dim oPres As PowerPoint.Presentation

Set oDoc = ActiveDocument
oDoc.PresentIt

On Error Resume Next
Set oPPT = GetObject(, "PowerPoint.Application")
If Err Then
PPTWasNotRunning = True
Set oPPT = New PowerPoint.Application
End If

With oPPT.Presentations(ActivePresentation)
.SaveAs ("C:\temp\scanned.ppt")
End With


Thanks again!
 

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