Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Menus and Toolbars / December 2005

Tip: Looking for answers? Try searching our database.

How to add Fractions along with their formatting as AutoText in a template

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ashish - 17 Dec 2005 14:45 GMT
I am basically working on VBA product of client.
I have tproblems facing of how add Fractions along with their formatting as
AutoText in a template created by me.I am successfully able to add fractions
in the category i desired but i am unable to retain the formatting of
fractions as they added during creating autotext for the same.When i insert
AutoText entry of particular fractions it loses the formatting & fist number
or char of Fractions takes the formatting of the cursor or previous text
formatting.I m very much frustrated by this since i m not able to get the
expected result.I have tried to add it programmatically as per the desired
formatting ,say,eg: for 1/2 I want "1" as Superscript with font size 8,"/" as
Italic with font size 9 with no Superscipt and "2" as font size 5.5 with no
superscript and no italic.,but i am unavle to get at what instance of Word
event should that macro for which programming is done be called so that i can
replace autotext entry value with the one i desired.Please help me in this
simple word form or hrough programmatically.Waiting for response

Thanks,
Ashish
Suzanne S. Barnhill - 17 Dec 2005 15:29 GMT
Is there some reason you're not using the made-up fractions built into every
font? These include not only ¼, ½, and ¾ but also similar fractions for the
thirds and eighths. If you need others, then they will need to be created
manually. For methods, see
http://word.mvps.org/FAQs/Formatting/CreateFraction.htm; perhaps one of
these methods will work better when saved as AutoText.

Signature

Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> I am basically working on VBA product of client.
> I have tproblems facing of how add Fractions along with their formatting as
[quoted text clipped - 14 lines]
> Thanks,
> Ashish
Ashish - 17 Dec 2005 15:39 GMT
By doing this also i m not able to get the required formatting for fractions
as desired as such saved in AutoText while inserting those from AutoText.U
try for it & check whether formatting is retained or lost by adding those in
AutoText with first num of fraction as superscript

>Is there some reason you're not using the made-up fractions built into every
>font? These include not only ¼, ½, and ¾ but also similar fractions for the
[quoted text clipped - 8 lines]
>> Thanks,
>> Ashish
Suzanne S. Barnhill - 17 Dec 2005 17:57 GMT
By doing what? If you use the built-in fractions, they are font characters
and require no special formatting; they will conform to the default
paragraph font, which I would imagine would be what you want.

FWIW, however, if I save the combination you describe as an AutoText entry,
it is inserted just as saved regardless of the size of surrounding text (the
font does change to match).

Also, you might try using the "division slash" (glyph 2215) instead of a
virgule; you'll find it is longer and more slanted.

Signature

Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> By doing this also i m not able to get the required formatting for fractions
> as desired as such saved in AutoText while inserting those from AutoText.U
[quoted text clipped - 13 lines]
> >> Thanks,
> >> Ashish
Graham Mayor - 18 Dec 2005 06:40 GMT
And autoCORRECT may be the better option than autoTEXT if the behaviour is
to echo Word's default fraction options?
Again the formatted fractions made up of multiple characters may be applied
in this manner.

For alternative fraction creation methods to that suggested by Suzanne see:

http://www.gmayor.com/createfraction.htm
or
http://gregmaxey.mvps.org/Formatted_Fractions.htm

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> By doing what? If you use the built-in fractions, they are font
> characters and require no special formatting; they will conform to
[quoted text clipped - 25 lines]
>>>> formatting as [quoted text clipped - 14 lines] Thanks,
>>>> Ashish
Ashish - 18 Dec 2005 13:44 GMT
i am not able to access site :
http://gregmaxey.mvps.org/Formatted_Fractions.htm
But i want to know i what Application event can i get to know to replace
AutoText entry when it is entered with that of the one which i need to insert
programmatically

>And autoCORRECT may be the better option than autoTEXT if the behaviour is
>to echo Word's default fraction options?
[quoted text clipped - 12 lines]
>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
>>>>> Ashish
Charles Kenyon - 18 Dec 2005 14:17 GMT
Did you look into AutoCorrect? Look at it before you start exploring
application events. You are talking about intercepting every keystroke to
check for a pattern and replace it. That is what AutoCorrect does, very
well, without a lot of overhead.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

>i am not able to access site :
> http://gregmaxey.mvps.org/Formatted_Fractions.htm
[quoted text clipped - 21 lines]
>>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
>>>>>> Ashish
Suzanne S. Barnhill - 18 Dec 2005 16:08 GMT
The reason I didn't suggest AutoCorrect to Ashish is that he is wanting to
store this entry in a template; formatted AutoCorrect entries are stored in
Normal.dot, and I don't know of any way to transfer them to another
template.

Signature

Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> Did you look into AutoCorrect? Look at it before you start exploring
> application events. You are talking about intercepting every keystroke to
[quoted text clipped - 25 lines]
> >>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
> >>>>>> Ashish
Greg Maxey - 18 Dec 2005 16:31 GMT
All, due to some carelessness, I have inadvertently deleted my formatted
fractions tips page.  I don't know when or how it happened but since I
backup over backups I have not only made the mistake, but copied it to the
backup file.  I am afraid that page is now in the dustbin of history.  I
don't even remember exactly its content so I won't be attempting to recreate
it anytime soon.  Sorry.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> i am not able to access site :
> http://gregmaxey.mvps.org/Formatted_Fractions.htm
[quoted text clipped - 19 lines]
>>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
>>>>>> Ashish
Suzanne S. Barnhill - 18 Dec 2005 17:26 GMT
Seems like it included a macro for creating fractions; perhaps you have that
stashed somewhere?

Signature

Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> All, due to some carelessness, I have inadvertently deleted my formatted
> fractions tips page.  I don't know when or how it happened but since I
[quoted text clipped - 26 lines]
> >>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
> >>>>>> Ashish
Greg Maxey - 18 Dec 2005 18:19 GMT
Yes I have some fraction macros and some of the images.  I just don't
remember how I had it put together.  Here is a couple of macros.  The first
inserts a fraction with a EQ field construction, the second directly formats
a fraction:

Public Sub Fraction()

Dim oNum As String
Dim oDen As String
Do
 oNum = InputBox("Enter numerator:", "Numerator")
   If oNum = "" Then
     MsgBox "Numerator cannot be left blank.", , _
     "Illogical expression"
   End If
Loop Until oNum <> ""
Do
 oDen = InputBox("Enter denominator:", "Denominator")
 If oDen = "0" Or oDen = "" Then
   MsgBox "Denominator cannot be zero or left blank.", , _
     "Illogical expression"
 End If
Loop While oDen = "0" Or oDen = ""
If oDen <> "" Then
ActiveDocument.Fields.Add Range:=Selection.Range, _
   Type:=wdFieldEmpty, _
   Text:="EQ \f(" & oNum & ", " & oDen & " )", _
   PreserveFormatting:=False
End If
End Sub

Sub InsertFraction()
Dim Expr As String
Dim Numerator As String
Dim Denominator As String
Dim NewSlashChar As String
Dim SlashPos As Integer
Dim bInvalid As Boolean
NewSlashChar = ChrW(&H2044)

Do
 bInvalid = False
 Expr = InputBox("Enter the fraction as numerator/denominator" _
        & " (e.g., 3/4, a/b, etc.):", "Enter Fraction")
 If Expr = "" Then Exit Sub
 SlashPos = InStr(Expr, "/")
 If SlashPos = 0 Or SlashPos = 1 Then
   bInvalid = True
   MsgBox "Format must be numerator/denominator" _
          & " (e.g., 3/4, a/b, etc.)." _
          & " Please try again.", , "Format Error"
 End If
 Numerator = Left(Expr, SlashPos - 1)
 Denominator = Right(Expr, Len(Expr) - SlashPos)
 If Denominator = "0" Then
   bInvalid = True
   If MsgBox("The denominator is a null value." _
             & " Do you want to override?", vbYesNo, _
             "Illogical Expression") = vbYes Then
         bInvalid = False
   End If
 End If
Loop While bInvalid
Selection.Font.Superscript = True
Selection.TypeText Text:=Numerator
Selection.Font.Superscript = False
Selection.TypeText Text:=NewSlashChar
Selection.Font.Subscript = True
Selection.TypeText Text:=Denominator
Selection.Font.Subscript = False
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Seems like it included a macro for creating fractions; perhaps you
> have that stashed somewhere?
[quoted text clipped - 35 lines]
>>>>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
>>>>>>>> Ashish
Charles Kenyon - 18 Dec 2005 18:25 GMT
That goes in my archives. Thank you.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Yes I have some fraction macros and some of the images.  I just don't
> remember how I had it put together.  Here is a couple of macros.  The
[quoted text clipped - 107 lines]
>>>>>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
>>>>>>>>> Ashish
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.