0% found this document useful (0 votes)
107 views

5 PDFsam Word-VBA-Tutorial

The document discusses how to access and use the VBA Editor in Microsoft Word to edit or create macros. It provides a simple example macro that opens a document, writes text to it, and then saves and closes it. It also briefly outlines the basics of creating macro procedures in VBA.

Uploaded by

babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views

5 PDFsam Word-VBA-Tutorial

The document discusses how to access and use the VBA Editor in Microsoft Word to edit or create macros. It provides a simple example macro that opens a document, writes text to it, and then saves and closes it. It also briefly outlines the basics of creating macro procedures in VBA.

Uploaded by

babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

When you click Edit, you open the VBA Editor.

Using the VBA Editor you can edit recorded


Macros or write a Word Macro from scratch. To access the VBA Editor use the shortcut ALT + F11
or click Visual Basic from the Developer Ribbon.

Simple Word Macro Example


This is a simple example of a Word VBA Macro. It performs the following tasks:

• Opens a Word Document


• Writes to Document
• Closes and Saves the Word Document.

Sub WordMacroExample()

‘Open Doc & Assign to Variable


Dim oDoc As Document
Set oDoc = Documents.Open(“c:\Users\someone\NewDocument.docx”)

‘Write To Doc
Selection.TypeText “www.automateexcel.com”
Selection.TypeParagraph

‘Save and Close Doc


oDoc.Save
oDoc.Close

End Sub

Word Macro Basics


All VBA code must be stored within procedures like this. To create a procedure in VBA type “Sub
WordMacroExample” (Where “WordMacroExample” is your desired Macro name) and press
ENTER. VBA will automatically add the parenthesis and End Sub.

AutoMacro:
VBA Add-in with Hundreds of Ready-To-Use Code Examples, Learn More
Code Generators, and much more!

You might also like