Filling MsGraph datasheet quickly from vb.net

  • Thread starter Thread starter JzP
  • Start date Start date
J

JzP

Hi,
I am writing an application to extract SQL data and put it out to
PowerPoint. I can create the PowerPoint slides from a template and,
having read the data into arrays in my program, I can fill the chart
datasheets but only one cell at a time. To fill 8 rows with 25 cells
on each takes about 15 seconds which is a pain.
I saw mention of a way of filling a datasheet from a Tab-delimited
array(I think), which was supposed to be much faster.
If anyone can point me in the right direction I'd be most grateful.

Thanks

John
 
Not sure but you can fill Excel cells from an array using a single call. If
you can do the same thing for PowerPoint it could help to speed up things.. A
PowerPoint discussion group could be more helpfull as it's rather relatedto
the PowerPoint programming model...

--
Patrice

"JzP" <[email protected]> a écrit dans le message de groupe de
discussion :
(e-mail address removed)...




- Show quoted text -

Hi Patrice,
I finally got it working. Must be getting old as I had some code from
way back which I had misplaced.

In case anyone else has a similar problem below is a bit of code which
may help.


Sub TestDatasheetFill()
'See if we can fill the datasheet from a tab-delimited string
ReDim saDatasheetArray(9, 53)
Dim intCol As Integer
Dim intRow As Integer

Dim s As New System.Text.StringBuilder

For intRow = 1 To 9
For intCol = 1 To 51
s.Append(intRow + intCol & vbTab)
Next
s.Append(intRow + intCol)
s.Append(vbCrLf)
Next
blnClipboardCopyOK = True
Dim intX As Integer = 0
copyit:
Try
Clipboard.SetDataObject(s.ToString)
Catch ex As Exception
If intX < 5 Then
Debug.WriteLine("Copy failed - Loop =" & intX)
Threading.Thread.Sleep(3000)
intX += 1
GoTo copyit
Else

MessageBox.Show("Clipboard copy failed on slide.")
blnClipboardCopyOK = False
End If
End Try
End Sub

'Then, assuming you have set up ochart to point at the chart object on
your slide, simply use ochart.application.datasheet.range("A1").paste
which puts the data into a range starting at the second row and the
second column.

Hope that's of use to someone.
If you need more details feel free to email me.

John
 
Back
Top