Note: Now save your document with the macro to retrieve your document with the macro later.Ĭlick on the "File" tab and choose "Save as". Now you can execute the recorded macro by using the shortcut key or use "Run" in the macros drop down list.
#Macro to insert text in word document code#
The following VBA code lines each insert a different type of text: Selection.TypeText Text:'this text' Selection.TypeText Text:MyText Selection. You may need the macro to insert numbers, do some standardization on wording, or some other text insertion. Note : you can also "pause" the macro and later resume. Inserting text is a common occurrence in macros. For example:Īfter writing the text you need to "Stop recording Macros" for this go to the "View" Tab and choose "Stop recording" within the Macros group. Now write the text that you need to repeat. To get the code we need to follow the below steps to launch VB editor: Sub CopyWorksheetsToWord () Dim wdApp As Word.Application, wdDoc As Word. Ideally, I would want 1 file to do this always for Yesterdays date (whatever that may be) and another file to do this for Fridays date (whatever that may be). With macro code, you can simply copy the data in one worksheet at one time & then word application will be launched automatically & VBA code will use paste command to insert the data into doc file. Write the Proper name of the macro within the Macro Name text box and click on the "Keyboard" button to add a Shortcut key for the macro (use this shortcut key later to run the macro).Įnter the combination of keys of the shortcut, like Alt + Ctrl + O and then click on the "Assign" button. I am trying to create an AutoOpen VBA Macro in Word 2010 files for automatically inserting the same dates into 2 different text boxes when I first open the file. Now click on the "Macros drop down list " and choose "Record Macro". Open you Word document and click on the "View Tab".
To implement a macro use the following procedure. To use this feature you just need to record a macro to do your repetitive work in Word 2013 and use it over and over in the future.