Solved

Create a PowerPoint table from TAB delimited string

Posted on 2008-10-27
9
500 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This video teaches viewers how to add simple and professional themes to their slides.
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: …

728 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