Paste Bug in Powerpoint/Excel

S

Sean McPoland

Hi y'all

ok please bear with me while I outline the scenario:

Office 2003 SP1
I have:
a scheduled task that executes an Excel worksheet.
The excel sheet has an auto_open macro that runs.

the macro gets data, creates charts and then calls
Powerpoint to transfer charts.

the powerpoint calls are:
Code:
For iCht = 1 To 10

Sheets("Chart" & iCht).Select

ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy

SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1,
ppLayoutBlank)
PPApp.ActiveWindow.View.GotoSlide
PPSlide.SlideIndex
With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select
' align the chart
PPApp.ActiveWindow.Selection.ShapeRange.Align
msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align
msoAlignMiddles, True
With PPApp.ActiveWindow.Selection.ShapeRange
.ScaleWidth 1.15, msoFalse,
msoScaleFromBottomRight
.ScaleHeight 1.15, msoFalse,
msoScaleFromBottomRight
End With
With PPApp.ActiveWindow.Selection.ShapeRange
.ScaleWidth 1.13, msoFalse,
msoScaleFromTopLeft
.ScaleHeight 1.13, msoFalse,
msoScaleFromTopLeft
End With
End With
Next

The problem statement is:

..Shapes.Paste.Select

This statement does NOT use the data that has been copied
into the clipboard via the ActiveChart.ChartArea.Copy
statement but OPENS EXCEL AGAIN, TWICE.

This of course creates a serious problem as I now have a
recursive call which is invalid and should NOT happen.

How do I know it happens twice: I step through the macro
to the invalid statement press F8 and it opens the Excel
sheet Driver and steps to the auto_open Sub statement, I
then force the cursor to the End Sub statement and click
F8 again, which OPENS EXCEL again, I do the same thing
(force the cursor) and this time the macro returns to the
proper place having correctly pasted the actual chart.

this is a Bug Surely - or can someone help me out in
solving it....even if it is a fudge..willing to pass the
sheet along with data for those brave enough.

Many thanks in advance
Kindest regards
Sean McPoland
 
B

Brian Reilly, MS MVP

Here's the line of code that I use to paste a copied object from the
clipboard into PPT. It is already selected when it is pasted so no
need to reselect it again.

appppt.ActiveWindow.View.Paste

In fact no need to even select all the stuff you are selecting in the
first place. But that's another subject.

Brian Reilly, PowerPoint MVP
 
S

Sean McPoland

Brian,

thanks but your line of code here does not work, as in it
fails exactly the same way as mine.

Ideas, would you like to have a go at the code?

regards
Sean
 
S

Sean McPoland

Hi Steve,

and many thanks for the info below but it does NOT work.
It generates exactly the same problem as what I get and
which Brian has also tried to solve.

Sorry about that, the only solution I have come up with
todate is to addthe following into my workbook_Open macro

Private Sub Workbook_Open()

If Left(ThisWorkbook.Name, 4) = "Book" Then
Else
sDriver
End If

End Sub

This bypasses the Driver macro and just exits when it
opens it when it shouldn't.

Willing to pass the code for analysis purposes if you want

regards
Sean



-----Original Message-----
Hi y'all

ok please bear with me while I outline the scenario:

No problem. Lots of detail is GOOD detail.


[snipsnip]

Dim oSh as Shape
With PPSlide
' paste and select the chart picture
' instead of this
' .Shapes.Paste.Select
' do
set oSh = .Shapes.Paste
' then for the rest, instead of
PPApp.ActiveWindow.Select etc.,
With oSh
.Align msoAlignCenters, Tru
.Scalewidth yada yada
.Etcetera
End With ' oSh
End with ' PPSlide

That should prevent activating the chart over and over and should also make
your code run a tad faster. Don't blink or you'll miss it. ;-)

' align the chart
PPApp.ActiveWindow.Selection.ShapeRange.Align
msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align
msoAlignMiddles, True
With PPApp.ActiveWindow.Selection.ShapeRange
.ScaleWidth 1.15, msoFalse,
msoScaleFromBottomRight
.ScaleHeight 1.15, msoFalse,
msoScaleFromBottomRight
End With
With PPApp.ActiveWindow.Selection.ShapeRange
.ScaleWidth 1.13, msoFalse,
msoScaleFromTopLeft
.ScaleHeight 1.13, msoFalse,
msoScaleFromTopLeft
End With
End With
Next
[/code]

The problem statement is:

..Shapes.Paste.Select

This statement does NOT use the data that has been copied
into the clipboard via the ActiveChart.ChartArea.Copy
statement but OPENS EXCEL AGAIN, TWICE.

This of course creates a serious problem as I now have a
recursive call which is invalid and should NOT happen.

How do I know it happens twice: I step through the macro
to the invalid statement press F8 and it opens the Excel
sheet Driver and steps to the auto_open Sub statement, I
then force the cursor to the End Sub statement and click
F8 again, which OPENS EXCEL again, I do the same thing
(force the cursor) and this time the macro returns to the
proper place having correctly pasted the actual chart.

this is a Bug Surely - or can someone help me out in
solving it....even if it is a fudge..willing to pass the
sheet along with data for those brave enough.

Many thanks in advance
Kindest regards
Sean McPoland

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA www.PowerPointLive.com
================================================

.
 

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