Setting the first row in a table in PPT using VBA

  • Thread starter Thread starter Wesslan
  • Start date Start date
W

Wesslan

Dear programmers out there,

I have managed to get the data I want from excel into PPT using VBA,
however, I have come across a small problem. As it is now I can only
import the data on the second row (numbered row 1). But I want the
pasting of values to start in the upper most left corner of the data
table in PPT.

The code I have used is:

Sub PPGraphMacro()

NoRows = 10
Set wbook = ActiveWorkbook
Template = "Waterfall template"
testsheet = "Waterfall data"
Sht = testsheet
'Defines the files to be used for opening and saving presentations
strPresPath = "C:\Documents and Settings\PWessel\My Documents
\Essentials\temp\" & Template & ".ppt"
strNewPresPath = "C:\Documents and Settings\PWessel\My Documents
\Essentials\temp\" & Template & " - output.ppt"

Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = msoTrue
Set oPPTFile = oPPTApp.Presentations.Open(strPresPath)
SlideNum = 1
oPPTFile.Slides(SlideNum).Select


'Updates graph
Rectangle = "Graph"
Set oPPTShape = oPPTFile.Slides(SlideNum).Shapes(Rectangle)
Set oGraph = oPPTShape.OLEFormat.Object

Range(wbook.Sheets(Sht).Cells(1, 2), wbook.Sheets(Sht).Cells(5,
NoRows + 2)).Copy
oGraph.Application.DataSheet.Range("00").Paste True

'Clears the settings before exiting
oGraph.Application.Update
oGraph.Application.Quit

oPPTFile.SaveAs strNewPresPath
oPPTFile.Close

Set oGraph = Nothing
Set oPPTShape = Nothing
Set oPPTFile = Nothing
Set oPPTApp = Nothing
Rectangle = ""
End Sub

Hence the problem is the
"oGraph.Application.DataSheet.Range("00").Paste True" where I have
specified the range as "00". I have also tried "A0" and so forth..
Anyone have a suggestion how to get the values pasted in the upper
left corner?

I appreciate any help/suggestions that can be given.

Kind regards,
 
Hi,

The reference to Range("00") works for me.
Are you sure the range you are copying from do not include extra row and
columns?

Cheers
Andy
 
Hi Andy,

This is really odd.. Now it works for me too. Anyhue thanks for the
reply ;) Have a great day!

Best regards,
 
Back
Top