martes, 3 de diciembre de 2013

How to Insert a Header with VBA

Insert headers with Visual Basic for Applications so you do not have to type the content by hand. This is useful, for example, if the first paragraph of each document you type contains the document title. VBA can automatically insert the title into the header after reading that paragraph. You do not have to know any Visual Basic statements to create the program. Instead, use your application's macro recorder to make it for you. If you want to understand how the program works, read its statements by opening the VBA programming environment by clicking the Developer tab's "Visual Basic" button. 

INSERT HEADER



Click the Developer tab's "Record" button in Word or Excel, then type a name for the macro in the dialog box that appears. For example, type "Insert Header." If you are using Excel and want to be able to later run the macro by pressing a keyboard key sequence, type the key sequence in the Shortcut text box. In Word, click the "Keyboard" button, then type the key in the Key text box.



Click "OK" to begin recording the macro.



Click the "View" tab in Word or Excel, then click the "Header" button. Word will display a list of commands related to headers. Click the list's "Edit" command to open the header area for editing. In Excel, clicking the "Header" button is sufficient to begin editing the header. The cursor is already positioned in the header, so you do not have to click "Edit" or another command.



Type some text in the header, such as "My Summer Vacation" or another document title, then click the "Close" header button on the toolbar.



Click the "Developer" tab, then click "Stop Recording."



Use the instructions from Step 3 to delete the header you typed in Step 4, then click the Developer tab's "Macros" button to display a list of macros, which will include your macro. Alternatively, press the shortcut key you specified in Step 3 to run the macro.



Double-click your macro's name to run the macro if you didn't assign a shortcut key. Notice that the application has reinserted the header you typed in Step 4.



 

No hay comentarios:

Publicar un comentario