VBA for technical writers - demo script

1,824 views

Published on

Script to accompany the slides with the same title (VBA for technical writers). These are resources from a talk given by Adrian Morse at Technical Communication UK 2011.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,824
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

VBA for technical writers - demo script

  1. 1. DEMO SCRIPT, VBA for Technical Writers<br />DemoInstructionsThe blue monkeyPLSTableListStarterOpen demo.docm. Click Developer>Record Macro…Name the macro “BlueMonkey” and keep in document, not template.Type “monkey”, use left arrow to select it.Apply bold, arial, 24pt, blue. Add a new pgf.Stop recording macro.ALT + F11 to open VB Editor.The bold blue monkeyPLSTableListStarterIn the VB Editor, open the module containing the blue monkey macro.Show empty demo.docm side by side. Make sure bold is turned OFF.Click F8 to step through macro and show that bold is applied.Now make sure bold is turned ON.Click F8 to step through and show bold is toggled off.Next to Selection.font.bold change wdToggle to True.With bold turned ON, run the macro again. Point out the bold has not been toggled off this time.The responsive blue monkeyPLSTableListStarterIn the VB Editor…cut blue monkey code from module and paste in ThisDocument in an “open” event.Delete all contents of document and turn bold off.Save and close document (do not close Word).Reopen document. Show that the macro runs.The inquisitive blue monkeyPLSTableListStarterClear the document.In the VB Editor, create a userform with a label and two buttons – yes and no.Copy the code from ThisDocument to the Yes button.In ThisDocument, remove the code and replace with:Load userform1Userform1.showFor both Yes and No buttons, add the following at the start:Unload userform1Save and close document (do not close Word).Reopen document. Show there is now a GUI.The loopy blue monkeyPLSTableListStarterClear the document.In the VB Editor userform, open the Yes button code and add the following around the code:For x = 1 to 10….Next xSave and close document (do not close Word).Reopen document. Show the word monkey appears 10 times.The increasingly loopy blue monkeyPLSTableListStarterClear the document.In the VB Editor userform, open the Yes button code and change the font setting to 24 + 2*x.Save and close document (do not close Word).Reopen document. Show the word monkey appears 10 times.The conditional blue monkeyPLSTableListStarterClear the document.In the VB Editor, add the following to ThisDocument:If ActiveDocument.Name = "Blue.docm" Then …Else: MsgBox (“Rename the document to Blue.docm")End IfSave and close document (do not close Word).Reopen document. Show the msgbox appears.Close the document.Rename the file to Blue.docm.Reopen document. Show the blue macro code runs.<br />

×