Make your own Word Experiment Toolbox

  
With the macro recording and VBA code in Word, it is easy to automatically enter user-defined graphics or formulas. In practical work, many science teachers use Word to design teaching or write test papers and test questions. Some graphics, molecular formulas, and experimental equipment will be used repeatedly. If you need to repaint, re-enter or find the previous Word file every time you use it, it will be very troublesome. The author thinks of a way to implant the things we often use into Word templates, use them as menus or toolbars, and use them at any time, convenient and fast. The process of generating graphics is mainly how to use the graphics and macro recording to complete the automatic generation of graphics. Now, we use the “flat-bottomed flask” in the chemical experiment as an example to illustrate the generation of graphics. First, we open Word 2003 to create a blank document, select "Tools → Macro & Rarr; Record New Macro" menu, enter the name of the macro in the pop-up "Record Macro" window, choose to save the macro in "All" Document (Normal.dot)”, OK; then, we can use the "Lines" line in the "Lines" tool to draw "round-bottom flask" and draw You can then set the line thickness, color, etc., and use the “Select Object” button in the drawing toolbar to select all of these lines, select the “Draw →Combination" menu to combine these lines into a whole, and Use the handle to adjust the size of the graphic. Finally, click the “Stop” button on the macro to stop recording the macro (Figure 1). Tip: If you can't use the drawing tool after selecting “record new macro”, you can select the “Tools → Options” menu and select the “General” tab in the pop-up window. Remove the "Automatically create a drawing canvas when inserting the AutoShape"; remove the front hook and click OK to close the window. The purpose of recording a new macro is to record your drawing process in the form of code, VBA code. Maybe you think the code is not very easy to understand, in fact, these VBA code is automatically generated by Word, you only need to modify it slightly. After the recording stops, select the “Tools & Rarr; Macro & Rarr; Macro” menu. In the pop-up window, the macro we just recorded is displayed. Select it and select the Edit button. A code editing window will appear. Automatically recorded drawing process code. We know that when drawing a graph, it is impossible to finish it very smoothly at one time, and it is inevitable to modify and delete it. These operations will be recorded by the macro to generate the corresponding code. These codes are useless to us. In the middle of the box), we can remove the code. In order to reuse this code, we also need to make a slight modification to this code, adding "lds;Documents.Add DocumentType:=wdNewBlankDocument" to the front of it to create a new blank document, the purpose is to draw in the new document. Replace the phrase "ActiveDocument.Shapes.Range(Array(…).Select” in the code with "ActiveDocument.Shapes.SelectAll", which means that all the graphics in the document are selected; at the end of the code, increase &ldquo ;Selection.Copy”,“ActiveWindow.Close (False)”, respectively, to copy the selected graphic, close and not save the current document (ie newly created blank document), paste the graphic in the document. If you want to draw later Flat-bottomed flasks, you can run this code directly. Regularly used graphics can be generated in this form to be saved and used directly in the future (Figure 2). The main process of establishing chemical formulas is mainly How to convert the process of inputting common chemical formulas into VBA code. The same method, Turn on “record new macros while typing the chemical formula you often make, it will also generate VBA code (Figure 3). The process of generating a custom toolbar is mainly to generate a custom toolbar, which will be in the form of a button. Call the VBA code. Imagine, we want to call these VBA code, but also select “tool → macro & rarr; macro & rdquo; menu, call out the window with a macro list to select the corresponding macro to run, it is trouble. If we Using our commonly used toolbar button form, the corresponding button corresponds to the corresponding macro name. Is it convenient and fast? First, we select the “Tools & Rarr; Customize” menu, and select ““ Toolbar” in the pop-up window. Label, click the "OK" button, enter the name of the toolbar in the new pop-up window, such as "Chemical Toolbox", which creates a toolbar. Because of the chemical graphics or molecular formula, we need Sort them, so you need to select the "command" label, select “new menu> in the category, in life To select the “New Menu”, drag it to the newly created “Chemical Toolbox” and right-click on the change tag name (Figure 4). The same method, if you want to divide into several categories, you need to drag a few times “ new menu & rdquo;, change the corresponding label content. Next, we need to put the corresponding macros into the various category menus. At this time, we select the "command" label, select “macro" in the category, drag the corresponding macro to the corresponding category menu, right click on the submenu, change its label name; also select &ldquo ; Edit button image & rdquo; to design an icon for the button (Figure 5). In the same way, we can create several toolbars and drag and drop the recorded macros into the corresponding categories. Toolbar Appearance and Hidden This process is mainly to customize a menu to show or hide several toolbars that you have created. There are more toolbars. If they all appear together in the Word window, it will look particularly messy. At this point, we can customize a menu to control the appearance of the toolbar. First of all, in order to open Word without displaying our newly created toolbar, we need to abbreviate a small piece of code. Select “Tools & Rarr; Macro & Rarr; Visual Basic Editor & rdquo;, for example, the author established the "common symbols", "Chemical Toolbox", "Physical Toolbox", these three toolbars, on the left In the window, expand the "Microsoft Word object" under the "Normal" and double-click the "ThisDocument" object, and enter the code in the image in the right window. This code means to hide the three toolbars. . Then, we select “tool → macro & rarr; macro & rdquo; menu, in the pop-up window, enter a macro name such as "Open chemistry toolbox", click the "Create" button, enter the map in the window The middle code, which means to display the corresponding toolbar (Figure 6). Next, we still select the “Tools & Rarr; Customize” menu, select the “Order” button in the pop-up window, select “New Menu” in the category, and select “New Menu” in the command. ;, drag it to the menu space in the Word window, right click on the new menu and change the title. Then select “ macro” in the category, drag these 3 macros to the new menu and right click to change the label title (Figure 7). In this way, you can use the menu to visualize the corresponding toolbar. Once the toolbar is displayed, you can click on the button above to automate the drawing, formula or automatic input of the formula. Tip: To use these macros, you also need to select the <;tools→macro →security" menu to set the security of the macro to low. Is this method convenient and quick for your repeated input? What are you waiting for, give it a try! This article comes from [System Home] www.xp85.com
Copyright © Windows knowledge All Rights Reserved