B
Bob
I'm trying to write a macro that creates a new slide at the end of a
presentation, creates a text box on it, and pastes text into the text box.
Here's the pertinent code:
ActivePresentation.Slides.Add(Index:=NumSlides + 1,
Layout:=ppLayoutText).Select
ActiveWindow.Selection.SlideRange.Layout = ppLayoutBlank
ActivePresentation.Slides(NumSlides + 1).FollowMasterBackground = msoFalse
ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizo
ntal, 0, 0, 720, 36).Select
With ActiveWindow.Selection.ShapeRange
.TextFrame.WordWrap = msoTrue
(other properties)
End With
ActiveWindow.Selection.TextRange.Font.Color.RGB = RGB(0, 0, 0)
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
ActiveWindow.Selection.TextRange.Text = CommentList
NumSlides and CommentList are "Dim"ed as Integer and String, respectively.
When I run the macro, it breaks in line 4 (adding the text box), and gives
the following error message:
Run-time error '-2147188160 (80048240)':
Shape (unknown member): Invalid request. To select a shape, its view must
be active.
Going back to the presentation, the new slide is not, in fact, active, so
this seems to make sense. However, if I put a breakpoint in the macro
(before line 4) and step through (F8) the rest of it, the macro works fine.
How do I get the slide active? I've tried playing with panes, windows, and
views, with no success. I've also tried using "Refresh" in different ways;
no joy here, either. Is there a different way to do this? What am I
missing?
Thanks,
Bob
presentation, creates a text box on it, and pastes text into the text box.
Here's the pertinent code:
ActivePresentation.Slides.Add(Index:=NumSlides + 1,
Layout:=ppLayoutText).Select
ActiveWindow.Selection.SlideRange.Layout = ppLayoutBlank
ActivePresentation.Slides(NumSlides + 1).FollowMasterBackground = msoFalse
ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizo
ntal, 0, 0, 720, 36).Select
With ActiveWindow.Selection.ShapeRange
.TextFrame.WordWrap = msoTrue
(other properties)
End With
ActiveWindow.Selection.TextRange.Font.Color.RGB = RGB(0, 0, 0)
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
ActiveWindow.Selection.TextRange.Text = CommentList
NumSlides and CommentList are "Dim"ed as Integer and String, respectively.
When I run the macro, it breaks in line 4 (adding the text box), and gives
the following error message:
Run-time error '-2147188160 (80048240)':
Shape (unknown member): Invalid request. To select a shape, its view must
be active.
Going back to the presentation, the new slide is not, in fact, active, so
this seems to make sense. However, if I put a breakpoint in the macro
(before line 4) and step through (F8) the rest of it, the macro works fine.
How do I get the slide active? I've tried playing with panes, windows, and
views, with no success. I've also tried using "Refresh" in different ways;
no joy here, either. Is there a different way to do this? What am I
missing?
Thanks,
Bob