vba code for comprehensive shape visibility


D

Dennis Meding

Hi,

at the moment I am using the following vba code in my presentation for
pictures to appear and/or disappear:

1.

Sub disappear(pic1 As Shape)
pic1.Visible = msoFalse
End Sub

2.

Sub appear()
Dim pic1 As Shape
For Each pic1 In ActivePresentation.SlideShowWindow.View.Slide.Shapes
pic1.Visible = msoTrue
Next
End Sub

This works great when I use both codes on the same slide.

My request is (for example) to give the picture on slide 1 the
onclick-command "disappear" and on slide 2 another shape the
onclick-command "appear". So when I click the Picture on slide 1 it
should disappear. When I click the shape on slide 2 the picture on slide
1 should appear again.

Could someone help me with the code?

Thanks and best regards,

Dennis Meding
 
Ad

Advertisements

G

Guest

Hi Dennis

I would first name the pics with vba for easy identification using something
like this (in edit mode):

Sub namer()
On Error GoTo errhandler
If ActiveWindow.Selection.ShapeRange.Count <> 1 Then Exit Sub
ActiveWindow.Selection.ShapeRange(1).Name _
= InputBox("Name me")
Exit Sub
errhandler:
MsgBox "Did you select something"
End Sub

Then to eg make a pic called "mypic1" on slide 1 visible use:
ActivePresentation.Slides(1).Shapes("mypic1").Visible = True
 
D

Dennis Meding

Hi John

Thank you! That works awesome!

Almost everything in my presentation works fine now, but I still have to
ask two questions:

a)

I'm using a code like this now for different shape-visibilities:

Sub Visibility1()
ActivePresentation.Slides(123).Shapes("shape1").Visible = msoTrue
ActivePresentation.Slides(123).Shapes("shape2").Visible = msoTrue
ActivePresentation.Slides(123).Shapes("shape3").Visible = msoFalse End Sub

I'm comparatively a VBA-"newbie", so I do not know if this code could be
written "shorter", because just shapes and visibilities change in each
line?


b)

Is there any possibility for a VBA-Code to start with a slide? As
described in your (great) newsletter, I tried an almost invisible shape
which starts with the slide. But I can just add macros to this shape on
click or on mouseover. It would be great if a macro and therefore the
visibilities of "slide no. 123" could be defined at the start of each
slide.

Thanks a lot,

Dennis
---
Dennis Meding
Diplom-Medienökonom (FH)
-----Ursprüngliche Nachricht-----
Von: John Wilson [mailto:john AT technologytrish.co DOT uk]
Bereitgestellt: Mittwoch, 18. Juli 2007 13:02
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: RE: vba code for comprehensive shape visibility

Hi Dennis

I would first name the pics with vba for easy identification using
something
like this (in edit mode):

Sub namer()
On Error GoTo errhandler
If ActiveWindow.Selection.ShapeRange.Count <> 1 Then Exit Sub
ActiveWindow.Selection.ShapeRange(1).Name _
= InputBox("Name me")
Exit Sub
errhandler:
MsgBox "Did you select something"
End Sub

Then to eg make a pic called "mypic1" on slide 1 visible use:
ActivePresentation.Slides(1).Shapes("mypic1").Visible = True
 
G

Guest

You would generally use a "with" statement here (not a lot shorter in this
instance)
Sub Visibility1()
With ActivePresentation.Slides(123)
..Shapes("shape1").Visible = msoTrue
..Shapes("shape2").Visible = msoTrue
..Shapes("shape3").Visible = msoFalse
End With
End Sub

The full screen invisible shape trick to run macros should run the macro if
you set it to mouseover and use kiosk mode - otherwise you are into event
handling which is a little tricky. Shyam has taken some of the work out of it
see here:
http://skp.mvps.org/autoevents.htm
 
D

Dennis Meding

I cannot use kiosk mode, because I need the speaker-view with the full
slideshow on a video projector & memos and time on a monitor.

The auto-events seem a bit challenging, but I think I will give it a try.

Thanks a lot for your help.

---
Dennis Meding
Diplom-Medienökonom (FH)


-----Ursprüngliche Nachricht-----
Von: John Wilson [mailto:john AT technologytrish.co DOT uk]
Bereitgestellt: Mittwoch, 18. Juli 2007 15:32
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: Re: vba code for comprehensive shape visibility

You would generally use a "with" statement here (not a lot shorter in this
instance)
Sub Visibility1()
With ActivePresentation.Slides(123)
..Shapes("shape1").Visible = msoTrue
..Shapes("shape2").Visible = msoTrue
..Shapes("shape3").Visible = msoFalse
End With
End Sub

The full screen invisible shape trick to run macros should run the macro
if
you set it to mouseover and use kiosk mode - otherwise you are into event
handling which is a little tricky. Shyam has taken some of the work out of
it
see here:
http://skp.mvps.org/autoevents.htm
--
Amazing PPT Hints, Tips and Tutorials-
http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk


Dennis Meding said:
Hi John

Thank you! That works awesome!

Almost everything in my presentation works fine now, but I still have to
ask two questions:

a)

I'm using a code like this now for different shape-visibilities:

Sub Visibility1()
ActivePresentation.Slides(123).Shapes("shape1").Visible = msoTrue
ActivePresentation.Slides(123).Shapes("shape2").Visible = msoTrue
ActivePresentation.Slides(123).Shapes("shape3").Visible = msoFalse End
Sub

I'm comparatively a VBA-"newbie", so I do not know if this code could be
written "shorter", because just shapes and visibilities change in each
line?


b)

Is there any possibility for a VBA-Code to start with a slide? As
described in your (great) newsletter, I tried an almost invisible shape
which starts with the slide. But I can just add macros to this shape on
click or on mouseover. It would be great if a macro and therefore the
visibilities of "slide no. 123" could be defined at the start of each
slide.

Thanks a lot,

Dennis
---
Dennis Meding
Diplom-Medienökonom (FH)
-----Ursprüngliche Nachricht-----
Von: John Wilson [mailto:john AT technologytrish.co DOT uk]
Bereitgestellt: Mittwoch, 18. Juli 2007 13:02
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: RE: vba code for comprehensive shape visibility

Hi Dennis

I would first name the pics with vba for easy identification using
something
like this (in edit mode):

Sub namer()
On Error GoTo errhandler
If ActiveWindow.Selection.ShapeRange.Count <> 1 Then Exit Sub
ActiveWindow.Selection.ShapeRange(1).Name _
= InputBox("Name me")
Exit Sub
errhandler:
MsgBox "Did you select something"
End Sub

Then to eg make a pic called "mypic1" on slide 1 visible use:
ActivePresentation.Slides(1).Shapes("mypic1").Visible = True



--
Amazing PPT Hints, Tips and Tutorials-
http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk
 
D

Dennis Meding

Hi,

there is a mysterious problem:

everything works fine now, BUT:

when I start the slide show, the different visibilities change in my
presentation, but not in my slideshow. that means: I see the different
shapes appear and disappear on my monitor on the different slides, but I
cannot see them on the same slide in my slide show on the beamer.

I hope I described this problem understandable.

---
Dennis Meding
Diplom-Medienökonom (FH)
-----Ursprüngliche Nachricht-----
Von: Dennis Meding [mailto:[email protected]]
Bereitgestellt: Mittwoch, 18. Juli 2007 15:58
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: Re: vba code for comprehensive shape visibility

I cannot use kiosk mode, because I need the speaker-view with the full
slideshow on a video projector & memos and time on a monitor.

The auto-events seem a bit challenging, but I think I will give it a try.

Thanks a lot for your help.

---
Dennis Meding
Diplom-Medienökonom (FH)


-----Ursprüngliche Nachricht-----
Von: John Wilson [mailto:john AT technologytrish.co DOT uk]
Bereitgestellt: Mittwoch, 18. Juli 2007 15:32
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: Re: vba code for comprehensive shape visibility

You would generally use a "with" statement here (not a lot shorter in this
instance)
Sub Visibility1()
With ActivePresentation.Slides(123)
..Shapes("shape1").Visible = msoTrue
..Shapes("shape2").Visible = msoTrue
..Shapes("shape3").Visible = msoFalse
End With
End Sub

The full screen invisible shape trick to run macros should run the macro
if
you set it to mouseover and use kiosk mode - otherwise you are into event
handling which is a little tricky. Shyam has taken some of the work out of
it
see here:
http://skp.mvps.org/autoevents.htm
--
Amazing PPT Hints, Tips and Tutorials-
http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk


Dennis Meding said:
Hi John

Thank you! That works awesome!

Almost everything in my presentation works fine now, but I still have to
ask two questions:

a)

I'm using a code like this now for different shape-visibilities:

Sub Visibility1()
ActivePresentation.Slides(123).Shapes("shape1").Visible = msoTrue
ActivePresentation.Slides(123).Shapes("shape2").Visible = msoTrue
ActivePresentation.Slides(123).Shapes("shape3").Visible = msoFalse End
Sub

I'm comparatively a VBA-"newbie", so I do not know if this code could be
written "shorter", because just shapes and visibilities change in each
line?


b)

Is there any possibility for a VBA-Code to start with a slide? As
described in your (great) newsletter, I tried an almost invisible shape
which starts with the slide. But I can just add macros to this shape on
click or on mouseover. It would be great if a macro and therefore the
visibilities of "slide no. 123" could be defined at the start of each
slide.

Thanks a lot,

Dennis
---
Dennis Meding
Diplom-Medienökonom (FH)
-----Ursprüngliche Nachricht-----
Von: John Wilson [mailto:john AT technologytrish.co DOT uk]
Bereitgestellt: Mittwoch, 18. Juli 2007 13:02
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: RE: vba code for comprehensive shape visibility

Hi Dennis

I would first name the pics with vba for easy identification using
something
like this (in edit mode):

Sub namer()
On Error GoTo errhandler
If ActiveWindow.Selection.ShapeRange.Count <> 1 Then Exit Sub
ActiveWindow.Selection.ShapeRange(1).Name _
= InputBox("Name me")
Exit Sub
errhandler:
MsgBox "Did you select something"
End Sub

Then to eg make a pic called "mypic1" on slide 1 visible use:
ActivePresentation.Slides(1).Shapes("mypic1").Visible = True



--
Amazing PPT Hints, Tips and Tutorials-
http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk
 
Ad

Advertisements

D

Dennis Meding

problem is solved.

I'm using the "FindBySlideID" command now. That works fine.

---
Dennis Meding
Diplom-Medienökonom (FH)
-----Ursprüngliche Nachricht-----
Von: Dennis Meding [mailto:[email protected]]
Bereitgestellt: Donnerstag, 19. Juli 2007 11:06
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: Re: vba code for comprehensive shape visibility

Hi,

there is a mysterious problem:

everything works fine now, BUT:

when I start the slide show, the different visibilities change in my
presentation, but not in my slideshow. that means: I see the different
shapes appear and disappear on my monitor on the different slides, but I
cannot see them on the same slide in my slide show on the beamer.

I hope I described this problem understandable.

---
Dennis Meding
Diplom-Medienökonom (FH)
-----Ursprüngliche Nachricht-----
Von: Dennis Meding [mailto:[email protected]]
Bereitgestellt: Mittwoch, 18. Juli 2007 15:58
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: Re: vba code for comprehensive shape visibility

I cannot use kiosk mode, because I need the speaker-view with the full
slideshow on a video projector & memos and time on a monitor.

The auto-events seem a bit challenging, but I think I will give it a try.

Thanks a lot for your help.

---
Dennis Meding
Diplom-Medienökonom (FH)


-----Ursprüngliche Nachricht-----
Von: John Wilson [mailto:john AT technologytrish.co DOT uk]
Bereitgestellt: Mittwoch, 18. Juli 2007 15:32
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: Re: vba code for comprehensive shape visibility

You would generally use a "with" statement here (not a lot shorter in this
instance)
Sub Visibility1()
With ActivePresentation.Slides(123)
..Shapes("shape1").Visible = msoTrue
..Shapes("shape2").Visible = msoTrue
..Shapes("shape3").Visible = msoFalse
End With
End Sub

The full screen invisible shape trick to run macros should run the macro
if
you set it to mouseover and use kiosk mode - otherwise you are into event
handling which is a little tricky. Shyam has taken some of the work out of
it
see here:
http://skp.mvps.org/autoevents.htm
--
Amazing PPT Hints, Tips and Tutorials-
http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk


Dennis Meding said:
Hi John

Thank you! That works awesome!

Almost everything in my presentation works fine now, but I still have to
ask two questions:

a)

I'm using a code like this now for different shape-visibilities:

Sub Visibility1()
ActivePresentation.Slides(123).Shapes("shape1").Visible = msoTrue
ActivePresentation.Slides(123).Shapes("shape2").Visible = msoTrue
ActivePresentation.Slides(123).Shapes("shape3").Visible = msoFalse End
Sub

I'm comparatively a VBA-"newbie", so I do not know if this code could be
written "shorter", because just shapes and visibilities change in each
line?


b)

Is there any possibility for a VBA-Code to start with a slide? As
described in your (great) newsletter, I tried an almost invisible shape
which starts with the slide. But I can just add macros to this shape on
click or on mouseover. It would be great if a macro and therefore the
visibilities of "slide no. 123" could be defined at the start of each
slide.

Thanks a lot,

Dennis
---
Dennis Meding
Diplom-Medienökonom (FH)
-----Ursprüngliche Nachricht-----
Von: John Wilson [mailto:john AT technologytrish.co DOT uk]
Bereitgestellt: Mittwoch, 18. Juli 2007 13:02
Bereitgestellt in: microsoft.public.powerpoint
Unterhaltung: vba code for comprehensive shape visibility
Betreff: RE: vba code for comprehensive shape visibility

Hi Dennis

I would first name the pics with vba for easy identification using
something
like this (in edit mode):

Sub namer()
On Error GoTo errhandler
If ActiveWindow.Selection.ShapeRange.Count <> 1 Then Exit Sub
ActiveWindow.Selection.ShapeRange(1).Name _
= InputBox("Name me")
Exit Sub
errhandler:
MsgBox "Did you select something"
End Sub

Then to eg make a pic called "mypic1" on slide 1 visible use:
ActivePresentation.Slides(1).Shapes("mypic1").Visible = True



--
Amazing PPT Hints, Tips and Tutorials-
http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk
 

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

Top