Results 1 to 2 of 2

Thread: Opening Word and Documents,,, Automation Error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    NC
    Posts
    29

    Opening Word and Documents,,, Automation Error

    I am having trouble opening Word and a document from VB (and Access for that matter)

    I copied the following code from the MSKB Q313193.

    Private Sub Command1_Click()

    Dim oWord As Word.Application
    Dim oDoc As Word.Document
    Dim oTable As Word.Table
    Dim oPara1 As Word.Paragraph, oPara2 As Word.Paragraph
    Dim oPara3 As Word.Paragraph, oPara4 As Word.Paragraph
    Dim oRng As Word.Range
    Dim oShape As Word.InlineShape
    Dim oChart As Object
    Dim Pos As Double

    'Start Word and open the document template.
    Set oWord = CreateObject("Word.Application")
    oWord.Visible = True
    Set oDoc = oWord.Documents.Add

    'Insert a paragraph at the beginning of the document.
    Set oPara1 = oDoc.Content.Paragraphs.Add
    .
    .
    .


    An instance of Word open with no document.
    When I hit the Set oDoc = oWord.Documents.Add statement I get
    Run-time error '-2147417851 (80010105)':
    Automation Error


    Anybody have any ideas on what would cause this.


    Thanks

    Bob T
    twick10

  2. #2
    New Member
    Join Date
    Jul 2002
    Posts
    12

    For a start

    You should dim oWord as an object, if you are going to run with late binding.

    Yeah ...

    Dim oWord as Object
    Set oWord = CreateObject("Word.Application")
    oWord.Documents.Add

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width