toggeling Macro

R

RVF

I have several Macro's thst toggle on/off see example text line on/off below

Sub text_wrap()
'
' text_wrap Macro
' Macro recorded 3/24/2008 by Raytheon
'
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom

If .WrapText = False Then

.WrapText = True

Else

.WrapText = False

End If

.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub

this works OK I am trying to write a macro that can zoom in to 120% and
then zoom back out to 100% my code below does not work

Sub zoom()
'
' Zoom Macro
' Macro recorded 3/15/2010 by
'
If ActiveWindow.zoom.Percentage = 120 Then

ActiveWindow.zoom.Percentage = 100
Else

ActiveWindow.zoom.Percentage = 120
End If

End Sub
 
L

Luke M

Correct coding is just:

ActiveWindow.Zoom = 100

Also, your Text_wrap sub could be greatly condensed to simply be:

With Selection
..WarpText = Not(.WrapText)
End With
 
P

Per Jessen

Try this one:

If ActiveWindow.Zoom = 120 Then
ActiveWindow.Zoom = 100
Else
ActiveWindow.Zoom = 120
End If

Regards,
Per
 
J

JLatham

Have you tried:

If ActiveWindow.Zoom = 100 Then
ActiveWindow.Zoom = 120
Else
ActiveWindow.Zoom = 100
End If

(or just to keep your logic)

If ActiveWindow.Zoom = 120 Then
ActiveWindow.Zoom = 100
Else
ActiveWindow.Zoom = 120
End If
 

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