| VBA - The Word Working Partner | |||||||||||||||||||||||||
| The Automated Tutorial Review Program | |||||||||||||||||||||||||
We're going to automate the complete process of building a review for this tutorial by building on the example just shown. Icons will be added to the standard toolbar to call the VBA programs and a few more programs will be written. First, add an icon that calls your VBA program to the standard toolbar by following these steps:
To continue my automated "Tutorial Rating System" I programmed a "RateIt" VBA Program that looks at the character just to the left of the text cursor and assigns a text rating if the character is from 1 to 5. Notice that this program is almost completely "traditional" Visual Basic. Here's that program: Sub RateIt()
Selection.MoveLeft _
Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Select Case Selection.Text
Case "1"
Selection.Text = _
"Huzza! Great! Loving It!"
Case "2"
Selection.Text = _
"Not the most wonderful but still quite good."
Case "3"
Selection.Text = _
"It's OK I guess. Seen better and seen worse."
Case "4"
Selection.Text = _
"It's a start but it needs work."
Case "5"
Selection.Text = _
"What a pile of GARBAGE!"
Case Else
Selection.Text = _
"Must be a number from 1 to 5. Try again."
End Select
End Sub
This program was assigned to a button on the tool bar as well. Next page > Using Toolbox Components > Page 1, 2, 3, 4, 5, 6 |
|||||||||||||||||||||||||

