PDA

View Full Version : Solved: toggle an object on/off?



TrippyTom
08-21-2006, 09:21 AM
Hi everyone...

I'm trying to make a macro that will toggle my predefined set of guidelines in PowerPoint. It's almost working (see partial code below) but I want to figure out a way to toggle the line on/off. And when I say off I mean not setting the .visible property to msoFalse. I don't want to be able to select the line at all when it's toggled off.

Here's my code:

ActiveWindow.Selection.SlideRange.Shapes.AddLine(342, 0, 342, 540).Select
With ActiveWindow.Selection.ShapeRange
.Name = "x2"
.Line.Weight = 0.05
.Line.ForeColor.RGB = RGB(255, 0, 0)
End With


Do you think this is possible?

TrippyTom
08-21-2006, 09:44 AM
I guess my 2nd question would be:
Can I lock an object from being moved?

geekgirlau
08-21-2006, 07:08 PM
Just a thought - what about putting the guideline on the slide master? Doesn't lock it, but certainly makes it much more difficult to get to.

TrippyTom
08-22-2006, 10:01 AM
hmmm... good idea :)

Still not sure how to toggle it on/off.

TrippyTom
08-25-2006, 09:34 AM
Well, I did some testing and if it's used as a 2nd slide master, objects won't snap to it, so that won't work. :think:

I'm back to square one. I want to:
1) Create the lines (done)
2) Group them
3) Somehow toggle them on/off on the current slide with a button (doesn't have to be document wide).

TrippyTom
10-04-2006, 09:58 AM
Would it make a difference if I defined my objects as a class? Would it be easier to work with them that way?

TrippyTom
10-04-2006, 04:41 PM
I changed my macro to put the lines in a Collection, them I marked each line with a specific key ("x1", "x2", etc).

Now I want to implement a toggle by checking if the lines already exist each time the macro is run. If they do, I want to remove all the lines.
Is this possible?

This is my code so far:


Sub GuidesAdd()
Dim myCol As New Collection
Dim i As Long

With myCol
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(23.76, 0, 23.76, 540), "x1"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(342, 0, 342, 540), "x2"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(360, 0, 360, 540), "x3"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(377.28, 0, 377.28, 540), "x4"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(696.24, 0, 696.24, 540), "x5"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(0, 48.24, 720, 48.24), "y1"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(0, 66.24, 720, 66.24), "y2"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(0, 102.24, 720, 102.24), "y3"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(0, 120.24, 720, 120.24), "y4"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(0, 300.24, 720, 300.24), "y5"
.Add ActiveWindow.Selection.SlideRange.Shapes.AddLine(0, 476.64, 720, 476.64), "y6"
End With
For i = myCol.Count To 1 Step -1
myCol(i).Line.Weight = 0.05
myCol(i).Line.ForeColor.RGB = RGB(255, 0, 0)
Next i
End Sub

TrippyTom
10-11-2006, 02:07 PM
Well, some of you may be happy to know I'm going to mark this solved because I ended up going in a completely different direction with this, and it works.

Thanks anyway. :hi: