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.
Driving Behavioral Change for Information Management through Data-Driven Gree...
VBA for technical writers - demo script
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 = quot;
Blue.docmquot;
Then …Else: MsgBox (“Rename the document to Blue.docmquot;
)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 />