Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / March 2008

Tip: Looking for answers? Try searching our database.

Setting the first row in a table in PPT using VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wesslan - 05 Mar 2008 10:59 GMT
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,
Andy Pope - 05 Mar 2008 15:26 GMT
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

Signature

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

> Dear programmers out there,
>
[quoted text clipped - 57 lines]
>
> Kind regards,
Wesslan - 06 Mar 2008 09:36 GMT
Hi Andy,

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

Best regards,

> Hi,
>
[quoted text clipped - 70 lines]
>
> - Show quoted text -

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.