Solved

Need macro code in 2010 word

Posted on 2016-10-19
5
19 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
Comment Utility
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 48

Expert Comment

by:Rgonzo1971
Comment Utility
Hi,

Could you send an example file?

Regards
0
 
LVL 5

Expert Comment

by:Austin Texas
Comment Utility
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 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
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 13

Expert Comment

by:frankhelk
Comment Utility
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

A Knowledge Base That Stays Up-to-Date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
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…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now