Word connectivity (continued) again

  • Thread starter Thread starter Nick 'The Database Guy'
  • Start date Start date
N

Nick 'The Database Guy'

I have discovered that this does not happen if you leave the word
document open the routine works ok over mulitple occurances, but if
you close it without saving, as you inevitabley have to then you
cannot write another letter, the occurance of word is started but does
not get any data, because of the error mentioned in the post 'Word
connectivity (continued)'.

Any help would be most appreciated.

Thanks in advance.

Nick
 
Hi Nick

I've haven't come across this before in Word but have experienced identical
responses with Outlook - i.e. GetObject works fine but CreateObject throws
the error you describe.

It seems that automation doesn't always recognise your local server so you
need to force it to do so by adding the second (should be optional but
isn't!) parameter to the CreateObject function.

So, try amending your CreateObject line to read:

Set appWord = CreateObject("Word.Application", "LocalHost")

This solves the Outlook problem and hopefully, as the problem is so similar,
will sort out your Word issue.

Cheers.

BW
 
I had the same problem with Excel. It was because I was using a variable
(Set xlSheet =Excel.Worksheet) to refer to a worksheet, then in the same
code I was referring to ActiveSheet. You may be doing the same. You have a
Docs variable but you refer to ActiveDocument. The following link explains
it better.

http://support.microsoft.com/kb/319832/en-us
 
Hi Nick

I've haven't come across this before in Word but have experienced identical
responses with Outlook - i.e. GetObject works fine but CreateObject throws
the error you describe.

It seems that automation doesn't always recognise your local server so you
need to force it to do so by adding the second (should be optional but
isn't!) parameter to the CreateObject function.

So, try amending your CreateObject line to read:

Set appWord = CreateObject("Word.Application", "LocalHost")

This solves the Outlook problem and hopefully, as the problem is so similar,
will sort out your Word issue.

Cheers.

BW

:







- Show quoted text -

Thanks BeWyched,

But unfortunatley it did not work.

Cheers

Nick
 
Back
Top