Saturday, November 27, 2010

As to the text in a Word document from VBA

Microsoft Visual Basic for applications (VBA) is a language in which programming, you save links for you to use time and keystrokes.

For example, if you constantly find themselves entering the same phrase in a Word document again, write a VBA macro or piece of executable code that can perform the task for you. Once you have written the code, that is you press a key, Word inserts the specified text. Difficulty: difficult

Instructions

Things you need: Microsoft Word 2007 or 2010
  1. 1

    Press "Alt" and "F11" from within the Word document where you want to insert the text.

  • 2

    Click "Insert" and then on "Modules" to open a blank module window.

  • 3

    Cut and paste the following code into the blank window: Sub MyTextIntoDocument()' MyTextIntoDocument selection.TypeText text macro: = _ "this is the text into a Word document inserted."

  • "Replace this text with the text you want to appear in your document". End Sub
  • 4

    Replace the text in the code with the text you want to insert into your document.

  • 5

    Press the "F5" key to run the macro.

  • No comments:

    Post a Comment