?
Solved

Need macro code in 2010 word

Posted on 2016-10-19
5
Medium Priority
?
35 Views
Last Modified: 2016-11-21
need superscript code in 2010 word document in macros
for all the double alphabets Ex:- aa bb cc dd upto zz
and for numeric numbers first no is superscript and second no is subsuperscript
0
Comment
Question by:suresh kandula
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:Austin Texas
ID: 41851475
Hi Suresh,

Let me make sure I understand what you are asking for. You need a macro that goes through the text of the document and looks for double letters (like "aa" and "bb") and where it finds them it changes them to superscript. Do I have that right?

And if there are double numbers, it will make the first digit superscript and the second digit subscript. Do I have that correct as well?
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 41851480
Hi,

Could you send an example file?

Regards
0
 
LVL 6

Expert Comment

by:Austin Texas
ID: 41852106
Suresh,

I haven't heard back from you with clarification so let me just say that I think the commands you are looking for are these:
.Characters([position]).Font.Subscript = [True/False]
.Characters([position]).Font.Superscript = [True/False]
I can help you write the script but will need to make sure if we are going the right direction.
0
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 41852203
Hi,

pls try
Sub Macro1()
Dim regExp As Object
Set regExp = CreateObject("vbscript.regexp")
Set doc = ThisDocument
With regExp
    .Pattern = "\W(([a-z]{2})|(\d{2}))\W"
    .Global = True
    
    Set Matches = .Execute(doc.Range.Text)

    For Each match In Matches
        strSubM = match.submatches(0)
        If Right(strSubM, 1) = Left(strSubM, 1) And IsEmpty(match.submatches(2)) Then    ' alphabetical
            doc.Range(match.FirstIndex + 1, match.FirstIndex + 3).Font.Superscript = True
        ElseIf IsEmpty(match.submatches(1)) Then                                         ' numeric
            doc.Range(match.FirstIndex + 1, match.FirstIndex + 2).Font.Superscript = True
            doc.Range(match.FirstIndex + 2, match.FirstIndex + 3).Font.Subscript = True
        End If
  Next

End With
End Sub  

Open in new window

Regards
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41895624
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Rgonzo1971 (https:#a41852203)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question