• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

PowerPoint 2013 store array data VBA

I have a PowerPoint app where I import some tabular data in a CSV file into an array. Of course I need to import the CSV each time I run it.

Is it possible for PowerPoint to store the data in a non-volatile way? For instance, is there a 'spreadsheet' within the PowerPoint 2013 that I can dump the data, so that it will persist?

If so can someone point me some sample VBA code?

  • 3
  • 2
1 Solution
You could store it in a series of presentation Tags maybe. If you post your csv file I can post more code but the basis is ....

ActivePresentation.Tags.Add "Name","Value"
hindersalivaAuthor Commented:
Hi JRSW, I have attached an example of a CSV file I need to import.

BTW I may be wrong but I seem to remember there was a 'spreadsheet object' in PowerPoint at one time that we could access programmatically?
The data csv needs to be on the desktop in this code (easy to change the path of course)

Read csv into Tags

Sub getData()
Dim iFileNum As Integer
Dim strPath As String
Dim strinput As String
Dim raySplit() As Long
Dim lineNum As Long
strPath = Environ("USERPROFILE") & "\Desktop\4MeasuresPerSlide.csv"
iFileNum = FreeFile
Open strPath For Input As #iFileNum
While Not EOF(iFileNum)
Line Input #iFileNum, strinput
lineNum = lineNum + 1
'strip extra "
strinput = Replace(strinput, Chr(34), "")
ActivePresentation.Tags.Add Name:="TAG" & CStr(lineNum), Value:=strinput
End Sub

Get values back for tag number (use call getTag(x))

Sub getTag(lngNum As Long)
Dim raySplit() As String
Dim tagName As String
Dim val1 As Long
Dim val2 As Long
Dim val3 As Long
Dim val4 As Long
Dim tagValue As String
tagName = "TAG" & CStr(lngNum)
tagValue = ActivePresentation.Tags(tagName)
raySplit = Split(tagValue, ",")
val1 = CLng(raySplit(0))
val2 = CLng(raySplit(1))
val3 = CLng(raySplit(2))
val4 = CLng(raySplit(3))
MsgBox "Value 1 = " & val1 & vbCrLf _
 & "Value 2 = " & val2 & vbCrLf _
& "Value 3 = " & val3 & vbCrLf _
& "Value 4 = " & val4
End Sub
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

hindersalivaAuthor Commented:
Thanks JSRW, I'll play around with that.
Stephen RindsbergCommented:
A chart in PowerPoint has a spreadsheet that you can access programmatically, but working with tags is a great deal simpler and more reliable across various PPT versions.
hindersalivaAuthor Commented:
Thanks Stephen. Ah, so that's what I seem to remember (but had forgotten). I'm working on the tags idea. That was new to me.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now