Conditional statement

J

jeanmac

Hi, I'm very new to VBA programming full stop, but absolutely new in
PowerPoint, all I want to do is write a little bit of code along the lines
of:

If selection.shaperange(1)=true then
ActiveWindow.Selection.ShapeRange(1).width = 260
else
msgbox "You must select the logo before you can resize it"

End if

I've been trying unsuccessfully for ages, and can't find help on it -
probably because it is too simple and I am too thick.

Any help would be really appreciated.

Thanks

Jeanmac
 
C

Chirag

While it is not entirely clear what you are trying to achieve with the code
snippet that you provided, it seems to me that you want to see if a shape is
selected. If a shape is selected then change its width otherwise show the
message. If yes, the following changed code should help you:

If ActiveWindow.Selection.Type = ppSelectionShapes Then
ActiveWindow.Selection.ShapeRange(1).Width = 260
Else
MsgBox "You must select the logo before you can resize it"
End If

- Chirag

OfficeOne Animations - Add over 50 animation effects to PowerPoint
http://officeone.mvps.org/anims/anims.html
 
J

jeanmac

Yes, that's exactly what I wanted, thank you!! I don't want them to get a
run time error if the click on the menu I've made to resize the shapes and
they don't have a shape selected. Which leads me to another question. In
Word I can creat a custom menu for a specific document which I can then save
as a template. As far as I can see in PowerPoint if I create a custom menu
it appears for the whole of PowerPoint, is that the case? Thanks for your
help, I do appreciate it.
 
C

Chirag

In PowerPoint, the macros are not linked with a document. If you create a
menu item for a macro, the menu item will continue to be there even if you
close the presentation. When you click the menu item, the presentation
should be open for it to execute properly. In case you want the macro to be
available for all presentations, you should create an add-in.

- Chirag

OfficeOne Animations - Add over 50 animation effects to PowerPoint
http://officeone.mvps.org/anims/anims.html
 
D

David M. Marcovitz

What Chirag said and ...

Note that the add-in will have to be installed on all machines that use
it. That is, it can't just be sent with a presentation or a template.

--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.loyola.edu/education/PowerfulPowerPoint/
 

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

Similar Threads


Top