excel VBA for auto open PowerPoint

G

Guest

I know it can be done. I had the code once. Anyway, I can copy and paste
excel to Powerpoint with an excel macro.. But I want the powerpoint to launch
from excel as if you clicked on the PPT icon...
Any ideas...
Thanks
DJ
 
R

Ron de Bruin

Hi Duncan

Try this

Dim pwp As Object
Set pwp = CreateObject("PowerPoint.Application")
pwp.Visible = True
pwp.presentations.Open Filename:="c:\test.ppt"
 
G

Guest

Can this same concept be used to open a specific Excel file from with in
Access?

Thanks,
Koataus
 
G

Guest

Hi Ron!
I pocked around and found this code which works great.

Sub Chart2PPT()
Dim objPPT As Object
Dim objPrs As Object
Dim shtTemp As Worksheet
Dim chtTemp As ChartObject
Dim intSlide As Integer

Set objPPT = CreateObject("Powerpoint.application")
objPPT.Visible = True
objPPT.presentations.Open ThisWorkbook.Path & "\Pres.ppt"
objPPT.ActiveWindow.ViewType = 1 'ppViewSlide

For Each shtTemp In ThisWorkbook.Worksheets
For Each chtTemp In shtTemp.ChartObjects
intSlide = intSlide + 1
chtTemp.CopyPicture
If intSlide > objPPT.presentations(1).Slides.Count Then
objPPT.ActiveWindow.View.GotoSlide
Index:=objPPT.presentations(1).Slides.Add(Index:=intSlide,
Layout:=1).SlideIndex
End If
objPPT.ActiveWindow.View.Paste
Next
Next
objPPT.presentations(1).Save
objPPT.Quit

Set objPrs = Nothing
Set objPPT = Nothing
End Sub

Thanks though
DJ
 
R

Ron de Bruin

Try this Koataus

Sub test()
On Error Resume Next
Set xl = GetObject(, "Excel.Application")
If xl Is Nothing Then
Set xl = GetObject("", "Excel.Application")
xl.workbooks.Open "c:\Data\book1.xls"
xl.UserControl = True
xl.Visible = True
End If
AppActivate "Microsoft Excel"
End Sub
 

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