Solved

Need macro code in 2010 word

Posted on 2016-10-19
5
28 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
  • 2
  • 2
5 Comments
 
LVL 5

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 49

Expert Comment

by:Rgonzo1971
ID: 41851480
Hi,

Could you send an example file?

Regards
0
 
LVL 5

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 49

Accepted Solution

by:
Rgonzo1971 earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Recursion / Iteration in Word 2013 Mail Merge 16 74
Microsoft Excel Digital Signature 2 55
VBA MS Word "Table of Contents" extractor` 4 41
vba - Word save error 11 10
Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.

772 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