Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Problem Copying Charts to PowerPoint

I have some Excel code that copies some Excel charts to PowerPoint. It's
giving me an error message that the clipboard is empty. Something in my code
must be emptying the clipboard, but I don't see what it is. The error
message occurs when I try to paste the chart at the last line of the code
shown below:

Range("Analysis_Left").CopyPicture Appearance:=xlScreen, Format:=xlPicture

'Open PowerPoint
Set myAPP = CreateObject("Powerpoint.Application")
myAPP.Visible = True
myAPP.WindowState = ppWindowMinimized
ThisWorkbook.Activate

'Create one new PowerPoint presentation and no more
If myAPP.Presentations.Count = 0 Then
Set ppPres = myAPP.Presentations.Add(msoTrue)
ppPres.Slides.Add 1, ppLayoutBlank

Else
NextSlide = 1 + (myAPP.ActivePresentation.Slides.Count)
myAPP.ActiveWindow.View.GotoSlide
Index:=myAPP.ActivePresentation.Slides.Add(NextSli de,
Layout:=ppLayoutBlank).SlideIndex

End If

'Paste the left side of the image into a PowerPoint slide
myAPP.ActiveWindow.View.Paste

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem Copying Charts to PowerPoint


Why not move the copypicture to the end of the macro. You may want to
change activesheet to sheets("Sheet1").



'Open PowerPoint
Set myAPP = CreateObject("Powerpoint.Application")
myAPP.Visible = True
myAPP.WindowState = ppWindowMinimized
ThisWorkbook.Activate

'Create one new PowerPoint presentation and no more
If myAPP.Presentations.Count = 0 Then
Set ppPres = myAPP.Presentations.Add(msoTrue)
ppPres.Slides.Add 1, ppLayoutBlank

Else
NextSlide = 1 + (myAPP.ActivePresentation.Slides.Count)
myAPP.ActiveWindow.View.GotoSlide
Index:=myAPP.ActivePresentation.Slides.Add(NextSli de,
Layout:=ppLayoutBlank).SlideIndex

End If

'Paste the left side of the image into a PowerPoint slide
thisworkbook.activesheet.Range("Analysis_Left").Co pyPicture
Appearance:=xlScreen, Format:=xlPicture

myAPP.ActiveWindow.View.Paste


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=199831

http://www.thecodecage.com/forumz

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Problem Copying Charts to PowerPoint

Thanks, I tried both of those things, and neither one has any effect.

I should have been more specific. The code works the first time I run it,
and also if I run it over and over, but if I click on the PowerPoint file and
go back to Excel and run the code again, then it doesn't work and I get the
error message that says the clipboard is empty. However, the clipboard can't
be empty because I can then manually paste from it straight into the
PowerPoint file. Somehow, by going into the PowerPoint file after the code
runs I am disrupting something.

"joel" wrote:


Why not move the copypicture to the end of the macro. You may want to
change activesheet to sheets("Sheet1").



'Open PowerPoint
Set myAPP = CreateObject("Powerpoint.Application")
myAPP.Visible = True
myAPP.WindowState = ppWindowMinimized
ThisWorkbook.Activate

'Create one new PowerPoint presentation and no more
If myAPP.Presentations.Count = 0 Then
Set ppPres = myAPP.Presentations.Add(msoTrue)
ppPres.Slides.Add 1, ppLayoutBlank

Else
NextSlide = 1 + (myAPP.ActivePresentation.Slides.Count)
myAPP.ActiveWindow.View.GotoSlide
Index:=myAPP.ActivePresentation.Slides.Add(NextSli de,
Layout:=ppLayoutBlank).SlideIndex

End If

'Paste the left side of the image into a PowerPoint slide
thisworkbook.activesheet.Range("Analysis_Left").Co pyPicture
Appearance:=xlScreen, Format:=xlPicture

myAPP.ActiveWindow.View.Paste


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=199831

http://www.thecodecage.com/forumz

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem Copying Charts to PowerPoint


I think I found the problem. Your slide count is wrong. When you
create a new presentation it automatically creates a presentation with
one slide. So when you add a slide you have two slides. The number of
slides is always one created than your slide count

When you already have a presentation your slide count equals the number
of slides.

I remove the add slide from the case where you don't have a
presentation. then I removed the add 1 from the Next slide count.


'Open PowerPoint
Set myAPP = CreateObject("Powerpoint.Application")
myAPP.Visible = True
myAPP.WindowState = ppWindowMinimized
ThisWorkbook.Activate

'Create one new PowerPoint presentation and no more
If myAPP.Presentations.Count = 0 Then
Set ppPres = myAPP.Presentations.Add(msoTrue)

Else
NextSlide = myAPP.ActivePresentation.Slides.Count
myAPP.ActiveWindow.View.GotoSlide
Index:=myAPP.ActivePresentation.Slides.Add(NextSli de,
Layout:=ppLayoutBlank).SlideIndex

End If

'Paste the left side of the image into a PowerPoint slide
thisworkbook.activesheet.Range("Analysis_Left").Co pyPicture
Appearance:=xlScreen, Format:=xlPicture

myAPP.ActiveWindow.View.Paste


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=199831

http://www.thecodecage.com/forumz

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
Excel hangs when copying sheet with charts to Powerpoint TimS Excel Discussion (Misc queries) 2 November 12th 08 10:48 PM
Excel 2007 - copying charts to Word problem artemis Charts and Charting in Excel 8 May 2nd 08 09:33 PM
Copy/Paste Charts; Define Destination of Charts in PowerPoint ryguy7272 Excel Programming 2 January 24th 08 08:04 PM
Problems copying charts into PowerPoint B&WCHARTS Charts and Charting in Excel 8 September 5th 06 02:54 AM
vba for PowerPoint Charts KevDu Excel Programming 0 April 28th 04 05:43 PM


All times are GMT +1. The time now is 03:42 AM.

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"