max777
06-26-2015, 07:05 PM
I am trying to read a .txt file line by line, and output one line per slide.
Currently, in my powerpoint, I have one slide and one text box.
My logic for the vba is that it will create a new slide after reading each line, and print the new line from the .txt file onto the new slide.
However, I am getting an error on the line.
Sld.Shapes(1).TextFrame.TextRange.Text = strLine
Appreciate any help.
Sub ReadAsciiFile()
Dim Pre As Presentation
Dim Sld As Slide
Dim FileName As String
Dim FileNum As Integer
Dim i As Integer
Dim pptLayout As CustomLayout
Set Pre = ActivePresentation
' edit this:
FileName = "C:\Users\user\Desktop\veni.txt"
Open FileName For Input As #1
i = 1
While EOF(1) = False
Line Input #1, strLine
If Not Len(strLine) = 0 Then
Set pptLayout = ActivePresentation.Slides(1).CustomLayout
Set Sld = ActivePresentation.Slides(1)
Sld.Shapes(1).TextFrame.TextRange.Text = strLine
Set pptSlide = ActivePresentation.Slides.AddSlide(i + 1, pptLayout)
i = i + 1
End If
Wend
Close #1
End Sub
Currently, in my powerpoint, I have one slide and one text box.
My logic for the vba is that it will create a new slide after reading each line, and print the new line from the .txt file onto the new slide.
However, I am getting an error on the line.
Sld.Shapes(1).TextFrame.TextRange.Text = strLine
Appreciate any help.
Sub ReadAsciiFile()
Dim Pre As Presentation
Dim Sld As Slide
Dim FileName As String
Dim FileNum As Integer
Dim i As Integer
Dim pptLayout As CustomLayout
Set Pre = ActivePresentation
' edit this:
FileName = "C:\Users\user\Desktop\veni.txt"
Open FileName For Input As #1
i = 1
While EOF(1) = False
Line Input #1, strLine
If Not Len(strLine) = 0 Then
Set pptLayout = ActivePresentation.Slides(1).CustomLayout
Set Sld = ActivePresentation.Slides(1)
Sld.Shapes(1).TextFrame.TextRange.Text = strLine
Set pptSlide = ActivePresentation.Slides.AddSlide(i + 1, pptLayout)
i = i + 1
End If
Wend
Close #1
End Sub