Run-time error '462' word from access on second run through

Posted on 2009-12-20
Last Modified: 2013-11-27
works fine the first time but on the second time through it throws up a
erroro 462 server not available.
Have been through a fair few sites but still have not come up with a workable solution, may be another set of eyes.
thanks for your help

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

     Dim oRange
   Dim wdApp As Word.Application
   Dim doc As Object
   Dim CellSize As Integer
   Set wdApp = New Word.Application
   Set doc = wdApp.Documents.Add
   wdApp.Visible = True

   ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=10, NumColumns _
              :=1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
    Set wdApp = Nothing

    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command0_Click
End Sub
Question by:sydneyguy
    LVL 38

    Accepted Solution

    Try changing this:
            ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=10, NumColumns _
    To a more complete reference:
             Set doc = wdApp.ActiveDocument
              doc.Tables.Add Range:=Selection.Range, NumRows:=10, NumColumns _

    Author Comment

    will try this thanks, also have postd another word question re setting margins if your int

    Author Closing Comment

    thanks for the tip have made the adjustment and am making good head way

    Featured Post

    A Knowledge Base That Stays Up-to-Date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
    In a previous video Micro Tutorial here at Experts Exchange (, I explained how to get a free, one-month trial of Office …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now