2010年12月16日星期四

Word, how to break out scores

Q: If the problem such as 4 / 5 (five quarters) how to use the scores that come out? In Word, do not come out to play!

A: When editing a document technology, often need to enter the score, but Word can not directly enter the scores. There are two approaches: using Word itself of the EQ (Equation) field or formula editor. These two methods are not easy, I wrote a EnterFraction macros in the document can be easily inserted into points, which greatly simplifies the editing points. The following details how to create the Word 97/2000/XP macros.

1. Create a dialog window

Click the "Tools" * "macro" * "Visual Basic Editor" to start the Visual Basic Editor. Click on the menu bar command "insert" * "Add User Form", add a blank user form, add two labels on the form (Label), two text editor (TextBox) and two command buttons (CommandButton) control them, and then modify their properties.

Component attribute values

userform (named) frmEnterFraction

Caption Enter Score

TextBox1 (named) tbNumerator

Caption molecule expression:

TextBox2 (named) tbDenominator

Caption denominator expression:

CommandButton1 (named) btnOK

Caption OK

CommandButton2 (named) btnCancel

Caption Cancel

Then click the command button 1 (CommandButton1, btnOK), to add a command handler as follows:

Private Sub btnOK_Click ()

If tbNumerator.Text <> "" And tbDenominator.Text <> "" Then

fractionText = "EQ \ F (" tbNumerator.Text "," tbDenominator.Text ")"

Selection.FIElds.Add Range: = Selection.Range, Type: = wdFieldEmpty, Text: = _

fractionText, PreserveFormatting: = False

End If

frmEnterFraction.Hide

End Sub

Click the command button 2 (CommandButton2, btnCancel), to add a command handler as follows:

Private Sub btnCancel_Click ()

frmEnterFraction.Hide

End Sub

Activated to form the final event (UserForm_Activate) add the following program segment:

Private Sub UserForm_Activate ()

Load frmEnterFraction

End Sub

2. To create a macro to call the command dialog window

Click the Visual Basic Editor menu bar on the "insert" * "Add Module" command in the code editor window, enter the following program segment:

Sub EnterFraction ()

frmEnterFraction.Show

End Sub

After completing the steps above, save the entire work, switch back to Word, you can use the macro commands.

3. To use the macro command

Place the insertion point where you need to insert the location of scores, click "Tools" * "macro" * "macro" to open the macro dialog window, select the EnterFraction and run the macro, pop up a dialog window, respectively, in "Molecular Expressions" and "denominator expressions" edit box, enter the fraction of the numerator and denominator, click "OK" button to enter the scores. Use the macro command to insert the domain scores in the editing process is treated as a separate unit to treat the editor, greatly simplifying the layout more difficult. For example:. For convenience, you can define the macro on the toolbar, use, just click the Tools button to open the dialog window.

没有评论:

发表评论