LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with VBA export of cells to PowerPoint

Hi gurus,

I have simple problem that is apparently too tough for me to figure out
right now. I have a macro in Excel that loops, uses formulas to
populate cells in a range of cells to look like a chart, then opens
PowerPoint, copies the range, and then *is supposed to* paste the range
into a new slide and continue looping until the data is complete. I
have figured out how to do everything from opening Powerpoint, grabbing
the cells, and pasting them into a slide. I even figured out how to
create a new slide. The problem is for some reason, it always pastes
to the last slide in the presentation and just pastes the new graph
over the top of the old one. I know this is a simple matter of calling
out the correct active slide, but I am stumped. Any help? Here's some
code to chew on. There are three macros here to perform the function,
but I realize the problem lies in the last one "RangetoPresentation".

Sub OpenPP()
Dim objPPT As Object
Set objPPT = CreateObject("Powerpoint.application")
objPPT.Visible = True
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Set PPPres = objPPT.Presentations.Add
Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)
Application.Run "'Resume Tracker 2006.xls'!AAATest"
End Sub
----------------------------------------------------------------------------------------------
Sub AAATest()

Application.ScreenUpdating = True
Application.DisplayAlerts = False
On Error Resume Next

x = 1
Windows("Diverse Resume Tracker 2006.xls").Activate
Sheets("BGs").Select
Do While Cells(x, 1).Value < ""
Worksheets("Template").Range("B1").Value = Worksheets("BGs").Cells(x,
1).Value
Application.Run "'Resume Tracker 2006.xls'!OffersDelivered"
Application.Run "'Resume Tracker 2006.xls'!RangeToPresentation"
x = x + 1
Sheets("BGs").Select
Loop

Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub
--------------------------------------------------------------------------------------------

Sub RangeToPresentation()
' Set a VBE reference to Microsoft PowerPoint Object Library

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

' Make sure a range is selected
If Not TypeName(Selection) = "Range" Then
MsgBox "Please select a worksheet range and try again.",
vbExclamation, _
"No Range Selected"
Else
' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)
PPApp.ActiveWindow.ViewType = ppViewSlide

' Reference active slide
' **************I THINK THIS IS THE PROBLEM *****************
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRa nge.SlideIndex)

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

' Paste the range
PPSlide.Shapes.Paste.Select

' Align the pasted range
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
End If

End Sub

 
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
how do i create a macro to export a chart to powerpoint? NPAT Charts and Charting in Excel 1 November 16th 07 10:23 AM
Put a checkbox beside each chtobj's and then export selected to powerpoint Gunnar Johansson[_4_] Excel Programming 0 May 3rd 05 06:34 AM
export pivot table from excel to powerpoint ben Excel Programming 1 December 26th 04 01:39 PM
Export from Excel to Powerpoint Martin Los[_3_] Excel Programming 2 December 22nd 04 09:37 AM
How to export a picture or chart from Excel to PowerPoint? RADO[_3_] Excel Programming 2 November 3rd 03 01:15 PM


All times are GMT +1. The time now is 04:58 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"