Solved

Need macro code in 2010 word

Posted on 2016-10-19
5
34 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 51

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 51

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.

717 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