Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

adding slides via macro

318 views
Skip to first unread message

Berkan

unread,
Feb 19, 2002, 9:05:59 AM2/19/02
to
Hi,

i'm trying to insert a new, blank slide into an existing
Powerpoint, but I have the problem that the slide is just
inserted at the end of the ppt. I want that the new, blank
slide has to inserted after the current slide I'm actually
using.

for example:
I have a ppt with 20 slides and I'm working aktually in
slide no. 12 and now start my makro. So the new slide
should be inserted after slide 12 and not after slide 20.

My VBA-code look like this:
ActiveWindow.View.GotoSlide _
Index:=ActivePresentation.Slides.Add _
(ActivePresentation.Slides.Count + 1, _
Layout:=ppLayoutBlank).SlideIndex

What's wrong with my Code?

Thanx and many greeting
Berkan

Shyam

unread,
Feb 19, 2002, 9:51:09 AM2/19/02
to
Berkan,
Count property will return the number of slide in the presentation hence the
new slide will always get inserted at the end. Instead use the code below.

ActiveWindow.View.GotoSlide _
Index:=ActivePresentation.Slides.Add _

(ActiveWindow.View.Slide.SlideIndex + 1, _
Layout:=ppLayoutBlank).SlideIndex

Regards
Shyam Pillai

Shyam's ToolBox
http://www.mvps.org/skp/toolbox

"Berkan" <a...@berkan.de> wrote in message
news:4f7101c1b94e$8eb07080$39ef2ecf@TKMSFTNGXA08...

Michael Koerner

unread,
Feb 19, 2002, 9:32:09 AM2/19/02
to
Just out of curiosity, why go to all the trouble of writing a macro to insert a new slide, when all
you need is Ctrl+M

--
DO NOT POST ATTACHMENTS IN THIS NEWSGROUP
Michael Koerner [MS PPT MVP]

Got a PowerPoint wish/suggestion/beef?
Email msw...@microsoft.com with PowerPoint in the subject line

"Berkan" <a...@berkan.de> wrote in message news:4f7101c1b94e$8eb07080$39ef2ecf@TKMSFTNGXA08...

Bhaskar Reddy

unread,
Feb 19, 2002, 10:38:48 AM2/19/02
to
Hi,

Try this macro

ActiveWindow.View.GotoSlide
Index:=ActivePresentation.Slides.Add(ActiveWindow.Selection.SlideRange.Slide
Number + 1, Layout:=ppLayoutBlank).SlideIndex

I think ActivePresentation.Count will return the total number of slides and
hence you are adding at the last position.

Regds
Bhaskar Reddy.

---SNIP---

Hi,

---SNIP---


Berkan

unread,
Feb 19, 2002, 10:35:03 AM2/19/02
to
>.
>

Steve Rindsberg

unread,
Feb 19, 2002, 10:46:33 AM2/19/02
to
Berkan,

' Breaking it down into several steps because it's easier to understand:
Dim CurrentSlide as Long

' Get the index of the slide we're on now
CurrentSlide = ActivePresentation.Windows(1).View.Slide.SlideIndex

' Add a new slide right after it
ActivePresentation.Slides.Add Index:=CurrentSlide + 1, Layout:=ppLayoutTitle
' or whatever you like

; Go to the new slide
ActiveWindow.View.GoToSlide(CurrentSlide + 1)

--
If you attach a file, I'll never see your message. Please don't.
Steve Rindsberg, PowerPoint MVP
Email your PowerPoint suggestions to msw...@microsoft.com
Get the PPT FAQs at http://www.rdpslides.com/pptfaq/
RnR PPTools - http://www.pptools.com
------


Berkan <a...@berkan.de> wrote in message
news:4f7101c1b94e$8eb07080$39ef2ecf@TKMSFTNGXA08...

Steve Rindsberg

unread,
Feb 19, 2002, 1:30:02 PM2/19/02
to
> Just out of curiosity, why go to all the trouble of writing a macro to
insert a new slide, when all
> you need is Ctrl+M

I'd guess that the code Berkan posted was part of a larger thingie.
You can't do larger thingies with Ctrl+M. ;-)


Michael Koerner

unread,
Feb 19, 2002, 3:08:02 PM2/19/02
to
I agree that I have very limited knowledge regarding VBA code (probably less than zero). But wasn't
he/his code just asking how to insert a blank slide at the current position?

--
DO NOT POST ATTACHMENTS IN THIS NEWSGROUP
Michael Koerner [MS PPT MVP]

Got a PowerPoint wish/suggestion/beef?
Email msw...@microsoft.com with PowerPoint in the subject line

"Steve Rindsberg" <stop...@its.source> wrote in message news:e3bE3PXuBHA.2112@tkmsftngp05...

Steve Rindsberg

unread,
Feb 19, 2002, 11:01:14 PM2/19/02
to
> I agree that I have very limited knowledge regarding VBA code (probably
less than zero). But wasn't
> he/his code just asking how to insert a blank slide at the current
position?

You know more than you think, you see?
Exactly so.

But it's normal to post just snippets that illustrate the problem you're
having, chopped out of what might be a much larger wad of code. He may have
been doing something vastly more complex. Continental coastlines, fjords
and fiddly bits and all, enough to make the mice proud, you see, when along
comes this Vogon coder and ...

Have I got the plots all mixed up again?


Michael Koerner

unread,
Feb 20, 2002, 5:55:53 AM2/20/02
to
Ok, understood, next time, will try to read more into it <G>

"Steve Rindsberg" <stop...@its.source> wrote in message news:#hB9EPcuBHA.1892@tkmsftngp03...

0 new messages