Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2016, 11:26 AM
wardw wardw is offline Trying to change Regular to Superscript and vice versa Windows 7 64bit Trying to change Regular to Superscript and vice versa Office 2007
Advanced Beginner
Trying to change Regular to Superscript and vice versa
 
Join Date: Oct 2012
Posts: 56
wardw is on a distinguished road
Default Trying to change Regular to Superscript and vice versa

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
But compiling this gets "Method or data member not found", with Regular highlighted. There's no objection to Selection.Font.Superscript or .Subscript or many other designations, but I can't find out what the designation is for just regular, normal, unformatted text. Selection.Font.Normal triggers the error as well.

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
. . . and I'm not sure how to integrate that into my code. Do I need to specify all those parameters, or is there a simpler way to say "not superscript or subscript"?
Reply With Quote
  #2  
Old 07-01-2016, 11:57 AM
jpl jpl is offline Trying to change Regular to Superscript and vice versa Windows 7 64bit Trying to change Regular to Superscript and vice versa Office 2010 32bit
Advanced Beginner
 
Join Date: Jan 2016
Location: France
Posts: 33
jpl is on a distinguished road
Default

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
Reply With Quote
  #3  
Old 07-01-2016, 12:13 PM
jpl jpl is offline Trying to change Regular to Superscript and vice versa Windows 7 64bit Trying to change Regular to Superscript and vice versa Office 2010 32bit
Advanced Beginner
 
Join Date: Jan 2016
Location: France
Posts: 33
jpl is on a distinguished road
Default

There is a clumsiness in my code: we can delete(eliminate) the condition .Superscript = false
Reply With Quote
  #4  
Old 07-01-2016, 04:40 PM
wardw wardw is offline Trying to change Regular to Superscript and vice versa Windows 7 64bit Trying to change Regular to Superscript and vice versa Office 2007
Advanced Beginner
Trying to change Regular to Superscript and vice versa
 
Join Date: Oct 2012
Posts: 56
wardw is on a distinguished road
Default

Thanks so much, JPL; this worked fine for my purposes.
Reply With Quote
  #5  
Old 07-05-2016, 06:56 PM
macropod's Avatar
macropod macropod is offline Trying to change Regular to Superscript and vice versa Windows 7 64bit Trying to change Regular to Superscript and vice versa Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #6  
Old 07-07-2016, 01:14 AM
jpl jpl is offline Trying to change Regular to Superscript and vice versa Windows 7 64bit Trying to change Regular to Superscript and vice versa Office 2010 32bit
Advanced Beginner
 
Join Date: Jan 2016
Location: France
Posts: 33
jpl is on a distinguished road
Default

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".
Reply With Quote
  #7  
Old 07-07-2016, 11:58 AM
macropod's Avatar
macropod macropod is offline Trying to change Regular to Superscript and vice versa Windows 7 64bit Trying to change Regular to Superscript and vice versa Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hardly relevant, since the OP never specified subscript as a consideration for the format change...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
convert regular font, convert superscript font

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to change Regular to Superscript and vice versa 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
Trying to change Regular to Superscript and vice versa Regular (roman) character style doesn't change text to roman kcbenson Word 2 10-16-2014 01:31 PM
Trying to change Regular to Superscript and vice versa Sizing cells to pics (or even vice versa?) Guloluseus Excel 1 07-27-2014 11:24 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft