Microsoft Office Tutorials and References
In Depth Information
Set appWord = GetObject(, "Word.Application”)
appWord.Visible = True
Set doc = appWord.ActiveDocument
With doc
doc.Application.Selection.TypeText "This file was created " & Date
End With
End Sub
Creating a New Word Document
There will be times when you want to create a new file instead of working with an existing
Word document. To accomplish this task, you need to have an open instance of Word and
then you’ll create a new document.
The following example uses early binding, so the code to create a new document is the same
as if you were creating a new document from Word. Before you test this procedure, add the
Word Object Library to your procedure.
Sub CopyFromExcelToNewWordDocument()
Dim wdApp As Word.Application
On Error Resume Next
Set wdApp = GetObject(, "Word.Application”)
If wdApp Is Nothing Then
Set wdApp = GetObject("", "Word.Application”)
End If
On Error GoTo 0
With wdApp
.Visible = True
End With
With wdApp.Selection
.EndKey unit:=wdStory
End With
Set wdApp = Nothing
End Sub
Search JabSto ::

Custom Search