Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Linking with powerpoing using VBA

I'm using Peltier's code from here
http://peltiertech.com/Excel/XL_PPT.html#rangeppt to link my excel worksheet
in with powerpoint.

I want to populate 4 slides from different selections in excel. The problem
I'm having is that I can't figure out the code to move onto the next PPT
slide.

I've tried all variations on this, and i've renamed the slides and replaced
the 2 with the appropriate name, but everytime i get a complie error at
select.

Set PPSlide = PPPres.Slides(2).Select

How can I activate the next slide?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Linking with powerpoing using VBA

In PowerPoint it would be:

Dim theSlide As Slide
'
Set theSlide = ActivePresentation.Slides(2)
theSlide.Select

So in Excel, it should be:

Dim theSlide as PowerPoint.Slide
'
Set theSlide = PPres.Slides(2)
theSlide.Select

HTH,

Eric

"Emma" wrote:

I'm using Peltier's code from here
http://peltiertech.com/Excel/XL_PPT.html#rangeppt to link my excel worksheet
in with powerpoint.

I want to populate 4 slides from different selections in excel. The problem
I'm having is that I can't figure out the code to move onto the next PPT
slide.

I've tried all variations on this, and i've renamed the slides and replaced
the 2 with the appropriate name, but everytime i get a complie error at
select.

Set PPSlide = PPPres.Slides(2).Select

How can I activate the next slide?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Linking with powerpoing using VBA

Hi

I've tried that in excel and I'm getting the error "Slides (Unknown member):
Invalid request". I've renamed the slide using a macro to "Units" and have
replaced the 2 in the code below with units

So...
Dim theSlide as PowerPoint.Slide
'
Set theSlide = PPres.Slides("Units")
theSlide.Select


I've also tried without the quotation marks around units. Any ideas?

Thanks

Emma
"EricG" wrote:

In PowerPoint it would be:

Dim theSlide As Slide
'
Set theSlide = ActivePresentation.Slides(2)
theSlide.Select

So in Excel, it should be:

Dim theSlide as PowerPoint.Slide
'
Set theSlide = PPres.Slides(2)
theSlide.Select

HTH,

Eric

"Emma" wrote:

I'm using Peltier's code from here
http://peltiertech.com/Excel/XL_PPT.html#rangeppt to link my excel worksheet
in with powerpoint.

I want to populate 4 slides from different selections in excel. The problem
I'm having is that I can't figure out the code to move onto the next PPT
slide.

I've tried all variations on this, and i've renamed the slides and replaced
the 2 with the appropriate name, but everytime i get a complie error at
select.

Set PPSlide = PPPres.Slides(2).Select

How can I activate the next slide?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Linking with powerpoing using VBA

This version opens an existing PowerPoint file instead of creating a new one,
then adds some slides and selects the second slide. Watch for line wrap in
the code below!

Sub Control_PPT()
Dim PPTApp As PowerPoint.Application
Dim PPres As PowerPoint.Presentation
Dim theSlide As PowerPoint.Slide
Dim PPTFile As Variant
'
PPTFile = Application.GetOpenFilename("PowerPoint Files (*.ppt*),
*.ppt*", , "Select a PowerPoint File to Open", , False)
If (PPTFile = False) Then Exit Sub
'
Set PPTApp = New PowerPoint.Application
PPTApp.Visible = msoTrue
Set PPres = PPTApp.Presentations.Open(PPTFile, msoFalse, , msoTrue)
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
'
Set theSlide = PPres.Slides(2)
theSlide.Select
'
' Do other stuff here...
'
' Unload the PowerPoint stuff
'
Set theSlide = Nothing
Set PPres = Nothing
Set PPTApp = Nothing
'
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Linking with powerpoing using VBA

Hi

Thanks for your help on this. It is however not working as I wanted it to.
I want to avoid adding new slides if at all possible since each slide in the
presentation has a particular title that doesnt change. So i want to select
an exisiting slide in the active presentation.

The code below will paste the selection onto the 2nd slide however won't let
me move the shape since the slide isnt selected.

Also as a side issue do you have any ideas how to resize the shape from this
code or run a macro in powerpoint from here which will resize it?

Thanks again

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
' Reference active slide
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRa nge.SlideIndex)

'Select range
Sheets("PPT 4BLOCKER").Select
Range("c45:m76").Select

' Copy the range as a piicture
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

' Paste the range
PPSlide.Shapes.Paste.Select

' Position pasted chart

PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing

' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
' Reference active slide
Set PPSlide = PPPres.Slides(2)

'Select range
Sheets("PPT 4BLOCKER").Select
Range("c45:m76").Select

' Copy the range as a piicture
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

' Paste the range
PPSlide.Shapes.Paste.Select

' Position pasted chart

PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True


"EricG" wrote:

This version opens an existing PowerPoint file instead of creating a new one,
then adds some slides and selects the second slide. Watch for line wrap in
the code below!

Sub Control_PPT()
Dim PPTApp As PowerPoint.Application
Dim PPres As PowerPoint.Presentation
Dim theSlide As PowerPoint.Slide
Dim PPTFile As Variant
'
PPTFile = Application.GetOpenFilename("PowerPoint Files (*.ppt*),
*.ppt*", , "Select a PowerPoint File to Open", , False)
If (PPTFile = False) Then Exit Sub
'
Set PPTApp = New PowerPoint.Application
PPTApp.Visible = msoTrue
Set PPres = PPTApp.Presentations.Open(PPTFile, msoFalse, , msoTrue)
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
'
Set theSlide = PPres.Slides(2)
theSlide.Select
'
' Do other stuff here...
'
' Unload the PowerPoint stuff
'
Set theSlide = Nothing
Set PPres = Nothing
Set PPTApp = Nothing
'
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Linking with powerpoing using VBA

Hi

I've worked it out :)

Thank you very much for all your help Eric. Now i just need to work out how
to resize the picture :)

Set PPSlide = PPPres.Slides(2)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex

With PPSlide

' Paste the range
PPSlide.Shapes.Paste.Select

' Position pasted chart

PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

End With
"EricG" wrote:

This version opens an existing PowerPoint file instead of creating a new one,
then adds some slides and selects the second slide. Watch for line wrap in
the code below!

Sub Control_PPT()
Dim PPTApp As PowerPoint.Application
Dim PPres As PowerPoint.Presentation
Dim theSlide As PowerPoint.Slide
Dim PPTFile As Variant
'
PPTFile = Application.GetOpenFilename("PowerPoint Files (*.ppt*),
*.ppt*", , "Select a PowerPoint File to Open", , False)
If (PPTFile = False) Then Exit Sub
'
Set PPTApp = New PowerPoint.Application
PPTApp.Visible = msoTrue
Set PPres = PPTApp.Presentations.Open(PPTFile, msoFalse, , msoTrue)
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
'
Set theSlide = PPres.Slides(2)
theSlide.Select
'
' Do other stuff here...
'
' Unload the PowerPoint stuff
'
Set theSlide = Nothing
Set PPres = Nothing
Set PPTApp = Nothing
'
End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Linking with powerpoing using VBA

Recording a macro in PowerPoint gives this for sizing and positioning:

ActiveWindow.Selection.SlideRange.Shapes("AutoShap e 4").Select
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.74, msoFalse, msoScaleFromTopLeft
.ScaleHeight 0.79, msoFalse, msoScaleFromBottomRight
End With
With ActiveWindow.Selection.ShapeRange
.IncrementLeft 48#
.IncrementTop -6#
End With

You should be able to do that from Excel by referencing the PPT app,
something like "PPApp.Activewindow.Selection...". A little experimenting
will get you there!



"Emma" wrote:

Hi

I've worked it out :)

Thank you very much for all your help Eric. Now i just need to work out how
to resize the picture :)

Set PPSlide = PPPres.Slides(2)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex

With PPSlide

' Paste the range
PPSlide.Shapes.Paste.Select

' Position pasted chart

PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

End With
"EricG" wrote:

This version opens an existing PowerPoint file instead of creating a new one,
then adds some slides and selects the second slide. Watch for line wrap in
the code below!

Sub Control_PPT()
Dim PPTApp As PowerPoint.Application
Dim PPres As PowerPoint.Presentation
Dim theSlide As PowerPoint.Slide
Dim PPTFile As Variant
'
PPTFile = Application.GetOpenFilename("PowerPoint Files (*.ppt*),
*.ppt*", , "Select a PowerPoint File to Open", , False)
If (PPTFile = False) Then Exit Sub
'
Set PPTApp = New PowerPoint.Application
PPTApp.Visible = msoTrue
Set PPres = PPTApp.Presentations.Open(PPTFile, msoFalse, , msoTrue)
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
PPres.Slides.Add Index:=PPres.Slides.Count + 1, Layout:=ppLayoutBlank
'
Set theSlide = PPres.Slides(2)
theSlide.Select
'
' Do other stuff here...
'
' Unload the PowerPoint stuff
'
Set theSlide = Nothing
Set PPres = Nothing
Set PPTApp = Nothing
'
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object linking/Worsksheet linking/etc... MikeH Excel Discussion (Misc queries) 0 June 15th 09 05:26 PM
An error msg in Excel 2007 regarding Linking but no linking in fil Jugglertwo Excel Discussion (Misc queries) 0 September 12th 08 02:08 AM
Linking amy Excel Discussion (Misc queries) 4 May 11th 08 11:27 PM
Help with Linking mkerstei Excel Discussion (Misc queries) 1 August 3rd 05 05:46 PM
Need to create report in Powerpoing from Excel data sgupta17[_2_] Excel Programming 1 June 11th 04 12:07 AM


All times are GMT +1. The time now is 10:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"