Access.2007.VBA.Bibl..

(John Hannent) #1
FIGURE 6.5
Examining the Word MailMerge object in the Object Browser.

Creating a New, Blank Word Document ........................................................

The NewDocfunction creates a new, blank Word document based on the default Word template:

Public Function NewDoc()

On Error GoTo ErrorHandler

Dim appWord As Word.Application
Dim docs As Word.Documents
Dim doc As Word.Document

Set appWord = GetObject(Class:=”Word.Application”)
Set docs = appWord.Documents
docs.Add
Set doc = appWord.ActiveDocument

ErrorHandlerExit:
Exit Function

Part II Writing VBA Code to Exchange Data between Office Components

Free download pdf