Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need macro code in 2010 word

Posted on 2016-10-19
5
Medium Priority
?
36 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 53

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 53

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

618 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