In: Computer Science
1. Open Microsoft Word
2. On the first line, type the words Word VBA Test Bed
3. Save the document as WordVBATestBed.docm. (It is vital that this is a macro-enabled document.)
4. Ensure that the Developer Tab is visible.
5. Ensure that the Visual Basic Editor is setup in accordance with pages 87 and 88 in the textbook.
6. Insert a module into this document.
7. Add the Option Base 1 instruction under Option Explicit.
4. Using the Visual Basic Editor, create a VBA procedure named create_object that does the following: a. Creates a variable of the Object type. b. Using the Set command, assign the third word of the first paragraph of the active document to the variable. c. Using appropriate methods, make the object bold. d. When you test the procedure, the third word of your document (test) should be bold.
It just needs to have "Option Explicit" at the beginning.
In case of any query, do comment. Please rate answer. Thanks
Please use below code in your module:
Option Explicit
Option Base 1
Sub create_object()
Dim word As Object 'a. create a variable of object type
'b. Using the Set command, assign the third word of the first paragraph of the active document to the variable
Set word = ActiveDocument.Paragraphs(1).Range.Words(3)
' c. Using appropriate methods, make the object bold , with .Font.Bold set to true
With word
.Font.Bold = True
End With
End Sub
================screen shot of the code===============================
Output: