• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 599
  • Last Modified:

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

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:= _
              wdAutoFitFixed
   
    Set wdApp = Nothing

Exit_Command0_Click:
    Exit Sub

Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click
   
End Sub
0
sydneyguy
Asked:
sydneyguy
  • 2
1 Solution
 
puppydogbuddyCommented:
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 _
0
 
sydneyguyAuthor Commented:
will try this thanks, also have postd another word question re setting margins if your int

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Word/Q_24993561.html
0
 
sydneyguyAuthor Commented:
thanks for the tip have made the adjustment and am making good head way
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now