Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-18-2012, 08:32 AM
Ulodesk Ulodesk is offline Fraction macro not working Windows 7 64bit Fraction macro not working Office 2010 64bit
Word 2013 Expert Cert
Fraction macro not working
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Fraction macro not working

Graham Mayor's site has the following macro, for converting non-autotext fractions to fractions. I can't get it to work on any fraction. VBA points to a problem in the line



TypeText Text:=sFraction(1)

Would someone let me know the correction required, please?


Code:
Sub FmtFraction()
 Dim sFraction() As String
 Dim sChar As String
 'Check if a fraction is selected
 'and if not show a warning and exit
 If InStr(Selection, "/") = False Then
  MsgBox "No fraction selected!", vbCritical, "Format Fraction"
  Exit Sub
 End If
 'Define a new slash character
 sChar = ChrW(&H2044)
 'Split the original fraction at the slash character
 sFraction = Split(Selection, "/")
 'Reformat the fraction using super and subscript
 With Selection
  .Font.Superscript = True
  .TypeText Text:=sFraction(0)
  .Font.Superscript = False
  .TypeText Text:=sChar
  .Font.Subscript = True
   TypeText Text:=sFraction(1)
  .Font.Subscript = False
 End With
 End Sub
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fraction macro not working macro not working (on click increment) gsrikanth Excel Programming 1 07-12-2012 07:40 AM
Fraction macro not working 'Little fraction' stopped? markg2 Word 5 01-31-2011 01:58 PM
Macro to open template not working Brandi Mail Merge 2 06-24-2010 09:29 AM
fraction not appearing correctly kcr Word 1 10-21-2009 03:51 PM
Word 2000 Macro not working properly brianlb Word VBA 1 07-01-2009 07:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft