Word Help

irishjoe

Registered User.
Local time
Today, 13:10
Joined
Apr 2, 2004
Messages
34
Hi,

I am exporting a table to word and I have come across a problem.
My code opens a template, creates a table with the correct number of rows and columns at a certain position, and then adds data to it.
At this point, everything is fine. But, here is where the problem sticks its ugly head out. I am modifying the column widths and every other time I run it, it crashes, saying something about not being able to access the remote server. Run time error 462.
I have checked in the task manager that word is being quit properly each time and tried going to different templates.
The first time I run it, it runs fine. The second time, it crashes on the line where I change the width. Here is the line of code.

mytable.Columns(1).Width = InchesToPoints(1.2)

I have found that if I close the document after it is created and leave word open, it will run fine.
I think I am in the same boat as mrpauly. But his post date is 23rd April 2001…
http://www.access-programmers.co.uk/forums/showthread.php?t=26363

Has anyone else seen or heard anything like this? I’m really confused…
Thanks for any help anyone can give.
 
Fixed it. Found a link to this on another forum.
http://support.microsoft.com/default.aspx?scid=KB;en-us;q188546

If you add this to the start, it opens correctly.

Dim temp As Word.Application
'Test if object is already created before calling CreateObject:
If TypeName(wrdApp) <> "Application" Then
Set temp = CreateObject("Word.Application")
Set wrdApp = CreateObject("Word.Application")
temp.Quit
Set temp = Nothing
End If
 

Users who are viewing this thread

Back
Top Bottom