Article ID: 189618
Article Last Modified on 4/16/2007
Option Explicit
Private Sub Command1_Click()
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oRange as Word.Range
Set oWord = CreateObject("Word.Application")
With oWord
.Visible = True
.Activate
.WindowState = wdWindowStateNormal
End With
Set oDoc = oWord.Documents.Add
MsgBox "Document open", vbMsgBoxSetForeground
With oDoc
.PageSetup.LeftMargin = InchesToPoints(1.25)
End With
' This example inserts text at the end of section one.
Set oRange = ActiveDocument.Sections(1).Range
With oRange
.MoveEnd Unit:=wdCharacter, Count:= -1
.Collapse Direction:=wdCollapseEnd
.InsertParagraphAfter
.InsertAfter "End of section."
End With
With oDoc
.Saved = True
End With
Set oRange = Nothing
Set oDoc = Nothing
oWord.Quit
Set oWord = Nothing
End Sub
.PageSetup.LeftMargin = InchesToPoints(1.25)-to-
.PageSetup.LeftMargin = oWord.InchesToPoints(1.25)
Set oRange = ActiveDocument.Sections(1).Range-to-
Set oRange = oWord.ActiveDocument.Sections(1).Range
178510 PRB: Excel Automation Method of Object '_Global'Failed
167223 Microsoft Office 97 Automation Help File Available
222101 HOWTO: Find and Use Office Object Model Documentation
Additional query words: activex OLE kbole kbActiveX kbAutomation kbVBp kbVBp400 kbVBp500 kbVBp600 kbWord twice second WD2007
Keywords: kbexpertiseinter kberrmsg kbprogramming kbautomation kbprb KB189618