Solved

Create a PowerPoint table from TAB delimited string

Posted on 2008-10-27
9
498 Views
Last Modified: 2013-11-07
Hi Experts,

Is there a way I can create a table (shape) in PowerPoint from a TAB delimited string. I am using VB.NET to automate PowerPoint with the XP PIA's.

I would like this to work with office XP and above,

Thanks in advance

Tom
0
Comment
Question by:TommyTwoPints
  • 4
  • 3
  • 2
9 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 22814902
Here is something that I created from a bigger code set, that goes against Office 2000, so it may or may not be a good starting place.


Imports System.Runtime.InteropServices
 
Public Class PowerPointServices
 
    Public Shared Sub CreatePresentationWithTable(ByVal presentationPath As String, ByVal tableText As String(,))
        Dim app As New PowerPoint.Application()
        app.Visible = Office.MsoTriState.msoTrue
 
        Dim presentation As PowerPoint.Presentation = app.Presentations.Open(presentationPath)
 
        Dim slide As PowerPoint.Slide = presentation.Slides.Item(1)
        slide.Select()
 
        Dim rowCount As Integer = tableText.GetUpperBound(0)
        Dim columnCount As Integer = tableText.GetUpperBound(1)
 
        slide.Shapes.AddTable(rowCount + 1, columnCount + 1)
 
        For row As Integer = 0 To rowCount
            For column As Integer = 0 To columnCount
                slide.Shapes.Item(1).Table.Rows.Item(0).Cells.Item(0).Shape.TextFrame.TextRange.Text = tableText(row, column)
            Next column
        Next row
 
 
        presentation.SaveAs(presentationPath)
        presentation.Close()
        app.Quit()
 
        Marshal.ReleaseComObject(slide)
        Marshal.ReleaseComObject(presentation)
        Marshal.ReleaseComObject(app)
 
    End Sub
 
End Class

Open in new window

0
 
LVL 21

Expert Comment

by:GlennaShaw
ID: 22816127
You should be able to modify one of these:
http://www.pptfaq.com/index.html#name_Working_with_external_data
0
 
LVL 3

Author Comment

by:TommyTwoPints
ID: 22828562
Thankyou both for your solutions. I take it there is no way of pasting a set of data to a PowerPoint table then?
With MSGraph.Charts, you can paste a TAB delimited string to the datagrid and it populates the charts very quickly. Doing things cell by cell is very slow with large amounts of data which is a bit of a problem.
Rgds
Tom
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Expert Comment

by:Bob Learned
ID: 22829590
Tom,

Let's not say that it is impossible, I just haven't needed to find a way (until now).  How is it done with MSGraph.Charts?
0
 
LVL 3

Author Comment

by:TommyTwoPints
ID: 22829778
You build a TAB delimited string based on your data
Copy the TAB delimited string to the clipboard
Create the range in the Chart.DataSheet <--- This should be the exact range your data will fill. If a different size range is selected then a message box appears asking you to confirm.
Call the Range.Paste method that will paste the data from the clipboard to the DataGrid.
If you need a code sample, let me know,
Rgds
Tom
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22829795
Tom,

There might be the same thing with the PowerPoint Range object.  You would need to get a reference to a Range object (which I think is doable) for the table.
0
 
LVL 21

Expert Comment

by:GlennaShaw
ID: 22843243
Couldn't you modify this one?
http://www.pptfaq.com/FAQ00891.htm
0
 
LVL 3

Author Comment

by:TommyTwoPints
ID: 22860709
Thankyou both for your help so far.
TheLearnedOne: As far as I can see, there is no Range object in PowerPoint. There is however a CellRange Interface which looks the most promising but I am not clear on hwow to use the interface without the table already existing.
GlennaShaw: I have seen that before but I am not sure it works with Office XP and above. I think that is only avaliable in Office 2003/2007.
0
 
LVL 3

Author Comment

by:TommyTwoPints
ID: 22865425
After some research of my own, I have decided to go with TheLearnedOne's solution. It seems to be the only way I can populate a table correctly over Office XP, 2003 and 2007.
Thanks alot
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VS 2015 is giving [No relevant source lines] 2 38
Code enhancement 4 32
Adding where clause to entity statement c# 1 46
visual studio vb.net windows onkeyup 2 25
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question