Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to toggle text orientation

Hi,

I write a lot of macros to simplify frequent steps, like turning the
AutoFilters on and off, i.e. toggling them.
Sub Toggle_AutoFilter()
Selection.AutoFilter
End Sub

That's probably my favorite. Use it all the time.

Another example is my Move On Enter macro that "toggles" from down to
right to off, based on the existing setting.

Sub Move_On_Enter()
'Toggle Move_On_Enter Feature
' 6/10/97
If Application.MoveAfterReturn = False Then
With Application
.MoveAfterReturn = True
.MoveAfterReturnDirection = xlDown
End With
ElseIf Application.MoveAfterReturnDirection = xlDown Then
Application.MoveAfterReturnDirection = xlToRight
ElseIf Application.MoveAfterReturnDirection = xlToRight Then
Application.MoveAfterReturn = False
End If
End Sub


So I'm trying to write one that will toggle the text orientation of the
selection from 0 to -90, and if it's not 0, then make it 0. I've tried
the following so far:

Sub ToggleTextOrientation()

If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation = -90 Then
Selection.Orientation = 0
End If

End Sub

I've also tried

If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation < 0 Then
Selection.Orientation = 0
End If

AND

Select Case Selection.Orientation
Case 90
Selection.Orientation = 0
Case -90
Selection.Orientation = 0
Case 0
Selection.Orientation = 90
Case Else
Selection.Orientation = 0
End Select

Doesn't seem like it would be tricky. I'm just not looking at it right.


I finally put a watch on Selection.Orientation. I get
Watch :
Expression: Selection.Orientation
Value: -4128
Type: Variant/Long
Context: Module2.ToggleTextOrientation

OK, it's in the back of my mind that -4128 is the datatype code, or
something like that.

If it was related to the orientation, I would have thought the "Else"
conditions would handle it, but no such luck.

Right now, I'm drawing a blank on getting past that. Or perhaps it's
another problem entirely. Any ideas would be appreciate. It's not
urgent; it's just bugging me.

Thanks,
Neva

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro to toggle text orientation

run this macro on a clean sheet (or put some text in C11)

Sub Checkit()
For i = -90 To 90 Step 1
Range("C11").Orientation = i
Cells(i + 91, 1) = i
Cells(i + 91, 2) = Range("C11").Orientation
Next
End Sub

and it should clear it up for you.

--
Regards,
Tom Ogilvy



" wrote:

Hi,

I write a lot of macros to simplify frequent steps, like turning the
AutoFilters on and off, i.e. toggling them.
Sub Toggle_AutoFilter()
Selection.AutoFilter
End Sub

That's probably my favorite. Use it all the time.

Another example is my Move On Enter macro that "toggles" from down to
right to off, based on the existing setting.

Sub Move_On_Enter()
'Toggle Move_On_Enter Feature
' 6/10/97
If Application.MoveAfterReturn = False Then
With Application
.MoveAfterReturn = True
.MoveAfterReturnDirection = xlDown
End With
ElseIf Application.MoveAfterReturnDirection = xlDown Then
Application.MoveAfterReturnDirection = xlToRight
ElseIf Application.MoveAfterReturnDirection = xlToRight Then
Application.MoveAfterReturn = False
End If
End Sub


So I'm trying to write one that will toggle the text orientation of the
selection from 0 to -90, and if it's not 0, then make it 0. I've tried
the following so far:

Sub ToggleTextOrientation()

If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation = -90 Then
Selection.Orientation = 0
End If

End Sub

I've also tried

If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation < 0 Then
Selection.Orientation = 0
End If

AND

Select Case Selection.Orientation
Case 90
Selection.Orientation = 0
Case -90
Selection.Orientation = 0
Case 0
Selection.Orientation = 90
Case Else
Selection.Orientation = 0
End Select

Doesn't seem like it would be tricky. I'm just not looking at it right.


I finally put a watch on Selection.Orientation. I get
Watch :
Expression: Selection.Orientation
Value: -4128
Type: Variant/Long
Context: Module2.ToggleTextOrientation

OK, it's in the back of my mind that -4128 is the datatype code, or
something like that.

If it was related to the orientation, I would have thought the "Else"
conditions would handle it, but no such luck.

Right now, I'm drawing a blank on getting past that. Or perhaps it's
another problem entirely. Any ideas would be appreciate. It's not
urgent; it's just bugging me.

Thanks,
Neva


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro to toggle text orientation

just to add, excel has the following defined constants and their
corresponding values:

xlDownward -4170
xlHorizontal -4128
xlupward -4171
xlVertical -4166

Select Case cell.orientation

case xlDownward ' -90

case xlHorizontal ' 0

case xlUpward ' 90

Case xlVertical

case else
' number of degrees

end Select


t
h
i
s

i
s

x
l
v
e
r
t
i
c
a
l


--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy


" wrote:

Hi,

I write a lot of macros to simplify frequent steps, like turning the
AutoFilters on and off, i.e. toggling them.
Sub Toggle_AutoFilter()
Selection.AutoFilter
End Sub

That's probably my favorite. Use it all the time.

Another example is my Move On Enter macro that "toggles" from down to
right to off, based on the existing setting.

Sub Move_On_Enter()
'Toggle Move_On_Enter Feature
' 6/10/97
If Application.MoveAfterReturn = False Then
With Application
.MoveAfterReturn = True
.MoveAfterReturnDirection = xlDown
End With
ElseIf Application.MoveAfterReturnDirection = xlDown Then
Application.MoveAfterReturnDirection = xlToRight
ElseIf Application.MoveAfterReturnDirection = xlToRight Then
Application.MoveAfterReturn = False
End If
End Sub


So I'm trying to write one that will toggle the text orientation of the
selection from 0 to -90, and if it's not 0, then make it 0. I've tried
the following so far:

Sub ToggleTextOrientation()

If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation = -90 Then
Selection.Orientation = 0
End If

End Sub

I've also tried

If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation < 0 Then
Selection.Orientation = 0
End If

AND

Select Case Selection.Orientation
Case 90
Selection.Orientation = 0
Case -90
Selection.Orientation = 0
Case 0
Selection.Orientation = 90
Case Else
Selection.Orientation = 0
End Select

Doesn't seem like it would be tricky. I'm just not looking at it right.


I finally put a watch on Selection.Orientation. I get
Watch :
Expression: Selection.Orientation
Value: -4128
Type: Variant/Long
Context: Module2.ToggleTextOrientation

OK, it's in the back of my mind that -4128 is the datatype code, or
something like that.

If it was related to the orientation, I would have thought the "Else"
conditions would handle it, but no such luck.

Right now, I'm drawing a blank on getting past that. Or perhaps it's
another problem entirely. Any ideas would be appreciate. It's not
urgent; it's just bugging me.

Thanks,
Neva


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to toggle text orientation

Tom,

Thank you for the info. I'm experimenting with both. However, it looks
to me as if the defined constants are for "ReadingDirection" rather
than Orientation, is that right?

Are there defined constants for Orientation?

I can no longer remember how to wade thru the Object Browser to a list
of these constants. Argh.

Thanks again,
Neva

Tom Ogilvy wrote:
just to add, excel has the following defined constants and their
corresponding values:

xlDownward -4170
xlHorizontal -4128
xlupward -4171
xlVertical -4166

Select Case cell.orientation

case xlDownward ' -90

case xlHorizontal ' 0

case xlUpward ' 90

Case xlVertical

case else
' number of degrees

end Select


t
h
i
s

i
s

x
l
v
e
r
t
i
c
a
l


--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy


"nwarnock" wrote:

<snip

I'm trying to write one that will toggle the text orientation of the
selection from 0 to -90, and if it's not 0, then make it 0. I've tried
the following so far:

Sub ToggleTextOrientation()

If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation = -90 Then
Selection.Orientation = 0
End If

End Sub


I finally put a watch on Selection.Orientation. I get
Watch :
Expression: Selection.Orientation
Value: -4128
Type: Variant/Long
Context: Module2.ToggleTextOrientation

OK, it's in the back of my mind that -4128 is the datatype code, or
something like that.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to toggle text orientation

Sorry, "readingorder"

wrote:
Tom,

Thank you for the info. I'm experimenting with both. However, it looks
to me as if the defined constants are for "ReadingDirection" rather
than Orientation, is that right?

Are there defined constants for Orientation?

I can no longer remember how to wade thru the Object Browser to a list
of these constants. Argh.

Thanks again,
Neva

Tom Ogilvy wrote:
just to add, excel has the following defined constants and their
corresponding values:

xlDownward -4170
xlHorizontal -4128
xlupward -4171
xlVertical -4166

Select Case cell.orientation

case xlDownward ' -90

case xlHorizontal ' 0

case xlUpward ' 90

Case xlVertical

case else
' number of degrees

end Select


t
h
i
s

i
s

x
l
v
e
r
t
i
c
a
l


--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy


"nwarnock" wrote:

<snip

I'm trying to write one that will toggle the text orientation of the
selection from 0 to -90, and if it's not 0, then make it 0. I've tried
the following so far:

Sub ToggleTextOrientation()

If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation = -90 Then
Selection.Orientation = 0
End If

End Sub


I finally put a watch on Selection.Orientation. I get
Watch :
Expression: Selection.Orientation
Value: -4128
Type: Variant/Long
Context: Module2.ToggleTextOrientation

OK, it's in the back of my mind that -4128 is the datatype code, or
something like that.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to toggle text orientation

LOL - Nope, I should have known better than to doubt you; those are of
course the ones for orientation!

wrote:
Sorry, "readingorder"

wrote:
Tom,

Thank you for the info. I'm experimenting with both. However, it looks
to me as if the defined constants are for "ReadingDirection" rather
than Orientation, is that right?

Are there defined constants for Orientation?

I can no longer remember how to wade thru the Object Browser to a list
of these constants. Argh.

Thanks again,
Neva

Tom Ogilvy wrote:
just to add, excel has the following defined constants and their
corresponding values:

xlDownward -4170
xlHorizontal -4128
xlupward -4171
xlVertical -4166

Select Case cell.orientation

case xlDownward ' -90

case xlHorizontal ' 0

case xlUpward ' 90

Case xlVertical

case else
' number of degrees

end Select


t
h
i
s

i
s

x
l
v
e
r
t
i
c
a
l


--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy


"nwarnock" wrote:

<snip

I'm trying to write one that will toggle the text orientation of the
selection from 0 to -90, and if it's not 0, then make it 0. I've tried
the following so far:

Sub ToggleTextOrientation()

If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation = -90 Then
Selection.Orientation = 0
End If

End Sub


I finally put a watch on Selection.Orientation. I get
Watch :
Expression: Selection.Orientation
Value: -4128
Type: Variant/Long
Context: Module2.ToggleTextOrientation

OK, it's in the back of my mind that -4128 is the datatype code, or
something like that.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Orientation of text in an autoshape Tonso Excel Discussion (Misc queries) 2 April 22nd 10 12:32 PM
Pagesetup.Orientation need VBA routine to "Best Guess" Orientation [email protected] Excel Discussion (Misc queries) 3 November 10th 09 05:53 PM
how to change orientation of text when cursor is passed over it? satindersingh Excel Discussion (Misc queries) 1 May 8th 09 03:54 PM
Can you toggle between different text colors while typing text Aloha Excel Discussion (Misc queries) 0 February 8th 06 05:10 PM
Print Orientation Toggle Alan Tolkoff Excel Programming 2 December 14th 04 01:30 AM


All times are GMT +1. The time now is 11:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"