![]() |
|
|
|
#1
|
|||
|
|||
|
I'm trying to build a macro that changes regular selected text to superscript and superscript text to regular. I'm using Code:
If Selection.Font.Superscript = True Then
With Selection.Font
.Superscript = False
End With
ElseIf Selection.Font.Regular = True Then
With Selection.Font
.Superscript = True
End With
End If
I tried to just record a macro by selecting a superscript and changing it to regular, but this is how "regular" was described . . . Code:
With Selection.Font
.Name = "Times New Roman"
.Size = 10
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = -0.15
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
|
|
#2
|
|||
|
|||
|
Peut être une solution :
Code:
Sub essai()
Dim c As Range
For Each c In Selection.Characters
With c.Font
If .Superscript = True Then
.Superscript = False
ElseIf .Superscript = False And .Subscript = False Then
.Superscript = True
End If
End With
Next c
End Sub
|
|
#3
|
|||
|
|||
|
There is a clumsiness in my code: we can delete(eliminate) the condition .Superscript = false
|
|
#4
|
|||
|
|||
|
Thanks so much, JPL; this worked fine for my purposes.
|
|
#5
|
||||
|
||||
|
To switch between regular & superscript, all you need is:
Code:
Sub Demo() With Selection.Font .Superscript = Not .Superscript End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#6
|
|||
|
|||
|
Bonjour à vous.
If the selection contains a mixture of regular, superscript and subscript, "Demo" changes selected text to superscript. "essai" changes regular to superscript, superscript to regular and respects subscript. On the other hand, "Demo" works on multiple selections, but not "essai". The problem results from the "Characters" collection. Si la sélection contient un mélange de caractères normaux, d'indices et d'exposants, la macro "Demo" transforme tout en exposant. La macro "essai" transforme les caractères normaux en exposants, les exposants en caractères normaux et respecte les indices. Par contre, la macro "Demo" fonctionne sur les sélections multiples, mais pas la macro "essai". Le problème provient de la collection "Characters". |
|
#7
|
||||
|
||||
|
Hardly relevant, since the OP never specified subscript as a consideration for the format change...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| convert regular font, convert superscript font |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Sub/superscript hotkey danish keyboard
|
Fakecake | OneNote | 1 | 04-05-2015 04:39 AM |
| excel update superscript by 1 | htownpaper | Word | 8 | 12-08-2014 06:38 PM |
| Insert superscript into a textbox | Deltaj | Word VBA | 3 | 11-30-2014 04:23 PM |
Regular (roman) character style doesn't change text to roman
|
kcbenson | Word | 2 | 10-16-2014 01:31 PM |
Sizing cells to pics (or even vice versa?)
|
Guloluseus | Excel | 1 | 07-27-2014 11:24 AM |