PDA

View Full Version : Copying via VBA Ranges from Excel



mferrisi
07-09-2008, 09:20 AM
Hello,

I have an Excel document that contains a macro that copies and pastes the ranges to a powerpoint slide.



Dim ppApp As Powerpoint.Application
Dim ppSlide As Powerpoint.Slide
Dim pShow As Presentation

RangeName = "ODateForm"
SheetName = "Control"
Worksheets(SheetName).Range(RangeName).Copy
ppSlide.Shapes.PasteSpecial(ppPasteHTML, link:=RangeLink).Select
ppApp.ActiveWindow.Selection.ShapeRange.Top = 82.125
ppApp.ActiveWindow.Selection.ShapeRange.Left = 514

SheetName = "Profile"
RangeName = "ProfHead"
Worksheets(SheetName).Range(RangeName).Copy
ppSlide.Shapes.PasteSpecial(ppPasteHTML, link:=RangeLink).Select
ppApp.ActiveWindow.Selection.ShapeRange.Top = 110
ppApp.ActiveWindow.Selection.ShapeRange.Left = 30

RangeName = "ProfileSum"
Worksheets(SheetName).Range(RangeName).Copy
ppSlide.Shapes.PasteSpecial(ppPasteHTML, link:=RangeLink).Select
ppApp.ActiveWindow.Selection.ShapeRange.Top = 132
ppApp.ActiveWindow.Selection.ShapeRange.Left = 36


etc. etc. (there are five more)

The pasted ranges are laid out in the proper places as I step though the code. However, when the last range is pasted, all of the pasted ranges move to different locations.

The fonts in the Excel ranges are blue. When the "ODateForm" is copied and pasted, it comes in blue. However, all of the others come in with black font, and remain with black font until the last range is pasted, at which time they change locations and turn to blue.

Is there a way I an get around this problem?

Thank you,

Matt