referencing selected insertion point in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i'm trying to write a macro to automatically insert slides and maintain the
formatting. i can reference a selected slide to insert before or after. But
i don't know how to reference the space in between the slide if it is
selected to insert the slide or slides into that space. how do i check if a
space is selected and reference it?
 
i'm trying to write a macro to automatically insert slides and maintain the
formatting. i can reference a selected slide to insert before or after. But
i don't know how to reference the space in between the slide if it is
selected to insert the slide or slides into that space. how do i check if a
space is selected and reference it?

In slide sorter view, correct? Interesting.

You can't reference the space because it isn't an object; it's the state of no
slide being selected. I don't think there's anything in the OM to tell you
where the cursor's sitting at that point, and that's what you need to know.

To determine whether you're in this state, you can trap the error when you do
something like:

ActiveWindow.Selection.ShapeRange(1).Name

or if you know you're in sorter view, check to see that
ActiveWindow.Selection.Type is non-zero

Once you've determined that nothing's selected you could use SendKeys:

Send a right-arrow, check the selection type again. If it's still 0, you're at
the end of the presentation so use .Slides.Count to determine the slide number
after which to insert new slides.
 
thanks Steve,
that's really helpful - it's strange that i can't reference the selected gap
between the slides directly since selecting that gap seems to be the most
common method of choosing an insertion point...
 
thanks Steve,
that's really helpful - it's strange that i can't reference the selected gap
between the slides directly since selecting that gap seems to be the most
common method of choosing an insertion point...

The gap isn't selected in any real sense. The fact that the cursor is sitting in
the gap is PPT's way of letting the user know that nothing's selected.

But I have to agree, there's a bit of information there that's not available via the
object model: the position of the cursor. Given all the other weird little bits of
 
Ben,

While you can't get the reference point of the cursor (insertion point), you
can insert slides at the insertion point using ActiveWindow.View.Paste
assuming that the current view is slide sorter view.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top