View Full Version : Access 2003 - Creating a Word Doc


oldozziesubby
10-27-2008, 12:35 AM
Hi, I have a problem that is causing me extreme frustration so I hope someone can help me.

I have created a maintenance database program that selects a number of maintenance tasks, groups them and then creates a word document with them.

It works great.... until I start adding tables to put the maintenance tasks in.

It creates the tables no problem.... the first time.

The next time it crashes with the following error code:"The remote Server or Machine does not exist or is unavailble".

I then close word down, go back to Access program and try again and it works????. It seems that it works the first time and then every second time after that. I am totally baffled.

It always crashes at the same spot and that is at the following code:

"objWord.ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:=3, DefaultTableBehavior:=wdWord9TableBehavior"

I have no idea why.

I hope there is somone who can help.

Thank you

Uncle Gizmo
10-27-2008, 01:49 AM
>>>I have no idea why.<<<<

You could try adding some error code to the routine, this may suggest where the problem is...

oldozziesubby
10-28-2008, 12:55 AM
Hi Uncle Gizmo, thanks for your reply.

Yes, I've tried using some error trapping (see Below) but it comes up with the same message plus the id of 462 (very helpfull)

Select Case Err
Case 4605
Selection.InsertBreak Type:=wdPageBreak
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend
Selection.Cells.Merge
Resume Next
Case 462
MsgBox "An Error" & vbCrLf & Err & ": " & Err.description
Case Else
objWord.ActiveDocument.Close
objWord.Quit
Set objWord = Nothing
Set db = Nothing
MsgBox Err & ": " & Err.Description, vbCritical, "Word Export"
End Select
Resume ExitHere