Hey Gang,
I am pretty new to VB in Excel and would still consider myself a novice, but I am having some difficulty getting text in Excel (2007) to populate in text boxes in PowerPoint. I have created the public function to define the parameters and also created a small sub to move text. When I run the sub I get this error: "Run-time error '5': Invalid procedure call or argument". When I run a debug of the sub, it steps through the sub fine and moves to reference the public function, then gives the same error when it hits this line
PPSlide.Shapes(textbox).TextFrame.TextRange = Text
You can see the full code for this section of the public function and how the above line fits in below.
Public Function copy_text(sheet, rowStart, columnStart, row_count, columnCount, slide, textbox)
Sheets(sheet).Select
Text = Cells(rowStart, columnStart).Resize(row_count, columnCount).Text
' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
PPApp.ActiveWindow.View.GotoSlide (slide)
' Reference active slide
Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
PPSlide.Shapes(textbox).TextFrame.TextRange = Text
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Function
I have looked this over a hundred times and have shown it to a number of different people, but no one can seem to pinpoint exactly what is going on. Is my public function wrong or am I referencing the spreadsheet incorrectly? Any help in this would be greatly appreciated. Thanks in advance!
-Bill
Bookmarks