icecurtain
Board Regular
- Joined
- Jun 24, 2010
- Messages
- 66
I would like this script to point to valuesFileName = "C:\words.txt"
because at the moment powerpoint comes up with an cannot find file error.
Can anyone amend script so it can find the .txt file?
it's purpose is to create individual text boxes from a list in a text file
because at the moment powerpoint comes up with an cannot find file error.
Can anyone amend script so it can find the .txt file?
it's purpose is to create individual text boxes from a list in a text file
Code:
Sub AddTextBoxes()
' Get a reference to the shapes collection
Dim workingShapes
Set workingShapes = Application.ActivePresentation.Slides(1).Shapes
' Prepare the working variables for getting the text box values
Dim valuesFileName As String
valuesFileName = "words.txt"
Dim valuesFile As Integer
Dim values() As String
Dim line As String
Dim lineLength As Long
Dim currentUpperBound As Long
currentUpperBound = -1
' Get the list of text box values
valuesFile = FreeFile
Open valuesFileName For Input As valuesFile
Do While Not EOF(valuesFile)
Line Input #valuesFile, line
lineLength = Len(line)
If lineLength > 0 Then
currentUpperBound = currentUpperBound + 1
ReDim Preserve values(0 To currentUpperBound)
values(currentUpperBound) = line
End If
Loop
Close #valuesFile
MsgBox ("Found " & (currentUpperBound + 1) & " values")
' Prepare the working variables for creating the text boxes
Dim counter, left, top, width, height, offsetLeft, offsetTop As Integer
Dim workingShape
Dim value As String
left = 10
top = 10
width = 200
height = 50
offsetLeft = 10
offsetTop = 10
' Create the text boxes
counter = 0
Do Until counter > currentUpperBound
value = values(counter)
Set workingShape = workingShapes.AddTextbox(msoTextOrientationHorizontal, left, top, width, height)
workingShape.TextFrame.TextRange.Text = value
left = left + offsetLeft
top = top + offsetTop
counter = counter + 1
Loop
End Sub
Last edited: