From: Bob on
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




From: PoohsMate on
Bob
There is an example of this in the book Powerful Powerpoint for educators -
try this as a search and you should find it. If not let me know and I will
post code (but it is quite long). HTH Bernard

"Bob" wrote:

> 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
>
>
>
>
>
From: David M. Marcovitz on
As Bernard suggests, you might find examples of this in my book (see
http://www.PowerfulPowerPoint.com/). However, you are trying to do this
in Normal View, and my book shows ways to do this in Slide Show View.

Why don't you try:

Dim oSld as Slide

oSld = ActivePresentation.Slides.Add(Index:=NumSlides + 1, ...

Then, instead of using ActiveWindow.Selection.SlideRange, you can use
oSld.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

"Bob" <wrong(a)invalid.net> wrote in
news:uOKnT9QHGHA.1452(a)TK2MSFTNGP11.phx.gbl:

> 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(msoTextOrientationH
> orizo 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
>
>
>
>

From: Bob on
Thanks, PM,

I will try to buy a copy of the book - looks helpful! There are quite a few
online examples and I haven't had time to look through all of them yet, but
the ones I saw look like they're activating a slide in a slideshow. I'm
tring to activate (or display) a slide in edit mode. Is there a difference?
If it's not too much trouble, could you post the example code so I can take
a look at it before getting the book?

Thanks, again!
Bob

"PoohsMate" <PoohsMate(a)discussions.microsoft.com> wrote in message
news:0E02183A-753C-4B7D-B455-65CE0C938268(a)microsoft.com...
> Bob
> There is an example of this in the book Powerful Powerpoint for
educators -
> try this as a search and you should find it. If not let me know and I will
> post code (but it is quite long). HTH Bernard
>
> "Bob" wrote:
>
> > 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
> >
> >
> >
> >
> >


From: David M. Marcovitz on
Bob,

You are right about the Edit mode vs. slide mode thing. Note that all
examples from the book are already online at
http://www.PowerfulPowerPoint.com/ and the code is even in text form. You
might want to start with Example 7.9 (click "Examples by Chapter" and
"Chapter 7").

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

"Bob" <wrong(a)invalid.net> wrote in
news:umaxNmRHGHA.524(a)TK2MSFTNGP09.phx.gbl:

> Thanks, PM,
>
> I will try to buy a copy of the book - looks helpful! There are quite
> a few online examples and I haven't had time to look through all of
> them yet, but the ones I saw look like they're activating a slide in a
> slideshow. I'm tring to activate (or display) a slide in edit mode.
> Is there a difference? If it's not too much trouble, could you post
> the example code so I can take a look at it before getting the book?
>
> Thanks, again!
> Bob
>
> "PoohsMate" <PoohsMate(a)discussions.microsoft.com> wrote in message
> news:0E02183A-753C-4B7D-B455-65CE0C938268(a)microsoft.com...
>> Bob
>> There is an example of this in the book Powerful Powerpoint for
> educators -
>> try this as a search and you should find it. If not let me know and I
>> will post code (but it is quite long). HTH Bernard
>>
>> "Bob" wrote:
>>
>> > 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(msoTextOrientationH
> orizo
>> > 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
>> >
>> >
>> >
>> >
>> >
>
>
>