I am trying to create a Macro that I can fun in PowerPoint to
automatically format fractions for me. I currently have a macro set
up in Word but when I copied it over to PowerPoint, it did not work.
I am pasting below what I am currently using in Word. Can someone
please correct this for me so that I may use it in PowerPoint? I do
not konw enough about Microsoft Visual Basic to do this myself.
Sub FmtFraction()
Dim OrigFrac As String
Dim Numerator As String
Dim Denominator As String
Dim NewSlashChar As String
Dim SlashPos As Integer
NewSlashChar = ChrW(&H2044)
OrigFrac = Selection
SlashPos = InStr(OrigFrac, "/")
Numerator = Left(OrigFrac, SlashPos - 1)
Denominator = Right(OrigFrac, Len(OrigFrac) - SlashPos)
With Selection
.Font.Superscript = True
.TypeText Text:=Numerator
.Font.Superscript = False
.TypeText Text:=NewSlashChar
.Font.Subscript = True
.TypeText Text:=Denominator
.Font.Subscript = False
End With
End Sub
Thanks a million!
Sue Ellen
Sub FmtFraction()
Dim OrigFrac As String
Dim Numerator As String
Dim intSelStart As Integer
Dim Denominator As String
Dim NewSlashChar As String
Dim SlashPos As Integer
NewSlashChar = ChrW(&H2044)
OrigFrac = ActiveWindow.Selection.TextRange
SlashPos = InStr(OrigFrac, "/")
Numerator = Left(OrigFrac, SlashPos - 1)
Denominator = Right(OrigFrac, Len(OrigFrac) - SlashPos)
intSelStart = ActiveWindow.Selection.TextRange.Start
With ActiveWindow.Selection.TextRange
.Font.Superscript = msoTrue
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=intSelStart + Len(Numerator), Length:=1).Select
ActiveWindow.Selection.TextRange.Font.Superscript = msoFalse
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=intSelStart + Len(Numerator) + 1, Length:=Len(Denominator)).Select
ActiveWindow.Selection.TextRange.Font.Subscript = msoTrue
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=intSelStart + Len(Numerator) + 2 + Len(Denominator), Length:=1).Select
ActiveWindow.Selection.TextRange.Font.Superscript = msoFalse
End With
End Sub
hope this will give you some idea?
regards,
-kc
*Click YES if this helps
Sub frac()
Dim oTxtr As TextRange
Dim iPos As Integer
If ActiveWindow.Selection.Type <> ppSelectionText Then Exit Sub
Set oTxtr = ActiveWindow.Selection.TextRange
iPos = InStr(oTxtr, "/")
If iPos < 1 Then Exit Sub
With oTxtr
.Characters(1, iPos - 1).Font.Superscript = True
.Characters(iPos) = ChrW(&H2044)
.Characters(iPos + 1, Len(oTxtr)).Font.Subscript = True
End With
End Sub
--
john ATSIGN PPTAlchemy.co.uk
Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
PPTLive Atlanta Oct 11-14 2009
Create "proper" fractions
http://www.pptfaq.com/FAQ00596.htm
In article <5a86eb8e-a32f-4faf-b590-
==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/
PPTools add-ins for PowerPoint
http://www.pptools.com/
Don't Miss the PPTLive User Conference! Atlanta | Oct 11-14