This is due to implicit instantiation. You are using a Word object that you
have not set up.
See http://support.microsoft.com/default.aspx?scid=kb;en-us;189618
Change to something like:
Set WD = CreateObject("Word.Application")
template = CurrentProject.Path & "\Invoice.dot"
Set DC = WD.Documents.Add(template)
Enjoy,
Tony
> Hi.
>
[quoted text clipped - 34 lines]
> Please anyone an idea of what this could be??
> Gina
Hi Tony.
tried your suggestion
Set DC = Word.Documents.Add(reVorlage, , , True)
Set DC = WD.Documents.Add(reVorlage, , , True) ... I get an error here
I sthere a possibility to Create an object
Set WD = CreateObject("Word.Application")
and add a document to it in one single step ???
maybe something like
Set WD = Word(CreateObject("Word.Application")).Documents.Add(template)
I am playing around with some syntax ... but don't know at all whether it is
possible
how could I destroy an object created like: Set WD =
CreateObject("Word.Application") ..
setting it to Set WD= Nothing .... doesn't close the word application
underneath
Thanks,
Gina
> This is due to implicit instantiation. You are using a Word object that you
> have not set up.
[quoted text clipped - 48 lines]
> > Please anyone an idea of what this could be??
> > Gina
Jonathan West - 10 Mar 2005 10:06 GMT
> Hi Tony.
>
[quoted text clipped - 10 lines]
>
> Set WD = Word(CreateObject("Word.Application")).Documents.Add(template)
Take two steps. One extra line of code is not a great hardship, and it gives
you an object variable for the Word application object, which you are likely
to need anyway.
> I am playing around with some syntax ... but don't know at all whether it
> is
[quoted text clipped - 4 lines]
> setting it to Set WD= Nothing .... doesn't close the word application
> underneath
Do this
WD.Quit
Set WD = Nothing

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Gina - 10 Mar 2005 11:28 GMT
Hi Jonathan.
tried it but get an error on WD.Quit
object wouldn't support this property or method
Dim WD As Object as public var in the current module
how will I find a way at all around this?? and when ???
Thanks for your answer
Gina
> > Hi Tony.
> >
[quoted text clipped - 28 lines]
> WD.Quit
> Set WD = Nothing
Jonathan West - 10 Mar 2005 11:42 GMT
Take a look at these two articles, and see what you are doing that is
different
Control Word from Excel
http://www.word.mvps.org/FAQs/InterDev/ControlWordFromXL.htm
Early vs. Late Binding
http://www.word.mvps.org/FAQs/InterDev/EarlyvsLateBinding.htm

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
> Hi Jonathan.
>
[quoted text clipped - 44 lines]
>> WD.Quit
>> Set WD = Nothing
Gina - 10 Mar 2005 12:39 GMT
Jonathan.
Thanks for the links - they are hopefully - or should be - what I need ....
will work through them and hopefully find the reason or my mistake.
sounds all quite complicated, whereas I don't think the thingi I intend to
do should be complicated at all.
I am doing a major mistake here in creating this word object ...
unbelievable.
Thanks again,
Gina
> Take a look at these two articles, and see what you are doing that is
> different
[quoted text clipped - 32 lines]
> >> >
> >> > Set WD =
Word(CreateObject("Word.Application")).Documents.Add(template)
> >> Take two steps. One extra line of code is not a great hardship, and it
> > gives
[quoted text clipped - 16 lines]
> >> WD.Quit
> >> Set WD = Nothing
Tony Jollans - 10 Mar 2005 11:49 GMT
If WD.Quit gives you that error then it is not a Word Application object.
Can you post all relevant code which you are now using.
Enjoy,
Tony
> Hi Jonathan.
>
[quoted text clipped - 44 lines]
> > WD.Quit
> > Set WD = Nothing
Gina - 10 Mar 2005 12:27 GMT
Tony, hi
well I start with
Option Compare Database
Option Explicit
Dim WD As Object
Dim DC As Word.Document
( If I do not create this WD I get an ActiveX error )
code in writeAddress(...) function
____________________________________
Set WD = CreateObject("Word.Document")
reVorlage = CurrentProject.Path & "\Rechnung1.dot"
Set DC = Word.Documents.Add(reVorlage)
....
....
____________________________________
at the end of all these diff. functions which write different parts I go
back to the main cmdInvoice
if the user has selected 'open up word' I call releaseWord which contains
________________________________
Public Sub ReleaseWord()
Set DC = GetObject(Word.ActiveDocument)
Set WD = Nothing
Set DC = Nothing
End Sub
_________________________________
when I press the cmdInvoice button next time around (after word has been
totally closed by the user) I get that 'remote-server-computer not existant
or not available'
and if I cklick 'debug' it highlights -->Set DC =
Word.Documents.Add(reVorlage)
if the user has selected 'print it' word and the created doc is invisible,
prints, gets closed and doesn't make any problems
__________________________
Public Sub PrintIt()
Set DC = GetObject(Word.ActiveDocument)
DC.PrintOut Copies:=2
DC.Close SaveChanges:=False
Set DC = Nothing
End Sub
__________________________
Is the active document not added to some sort of collection ..... do I need
to remove it?
Thanks for your help and interest
Gina
> If WD.Quit gives you that error then it is not a Word Application object.
>
[quoted text clipped - 30 lines]
> > > >
> > > > Set WD =
Word(CreateObject("Word.Application")).Documents.Add(template)
> > > Take two steps. One extra line of code is not a great hardship, and it
> > gives
[quoted text clipped - 16 lines]
> > > WD.Quit
> > > Set WD = Nothing
Tony Jollans - 10 Mar 2005 13:33 GMT
Hi Gina,
You are still not initialising correctly.
Firstly create a Word session:
Set WD = CreateObject("Word.Application")
Then, whenever you do anything with that Word session make sure you use WD.
Do not use Word.anything - use WD.anything instead.
Now create a document:
Set DC = WD.Documents.Add(yourtemplate)
When you reference the document use DC. When you reference Word use WD. Do
not use Selection on its own.
WHen you're done, do:
DC.Close
WD.Quit
Set DC = Nothing
Set WD = Nothing
Enjoy,
Tony
Gina - 10 Mar 2005 13:39 GMT
Thanks Tony
exactly that solved my problem now
create a ref to the application itself rather than a document
solved ... goodneess deary me - I am so glad!!!
Gina
> Hi Gina,
>
[quoted text clipped - 24 lines]
> Enjoy,
> Tony
Tony Jollans - 10 Mar 2005 10:31 GMT
Hi Gina,
To do it in one step you can use GetObject ..
Set myDoc = GetObject("mypath\mydoc.doc")
.. and that will create a Word application if necessary (or use an existing
one if present).
One disadvantage of this is that you don't have direct access to Word - you
have to use wdDoc.Application. You also don't know whether you have picked up
an existing object or created a new one, and so you don't know whether or not
to quit it afterwards.
To destroy the object you must quit the application and empty the object
pointer, so ..
myDoc.Application.Quit
Set myDoc = Nothing
But, beware doing it this way, that you don't lose access to your document
while the application is still active. Do you have a particular reason for
not wanting to instantiate separate Word and Document objects?
> Hi Tony.
>
[quoted text clipped - 79 lines]
> > > Please anyone an idea of what this could be??
> > > Gina
Gina - 10 Mar 2005 11:49 GMT
Hi Tony.
Thanks ....
> myDoc.Application.Quit
> Set myDoc = Nothing
tried it but get an error: method or property not available or valid (free
translation from german version).
I would like to see the application word with the active document so that
the user can do some amendments if it is wished - which can be done.
When the document - not the word application - is closed everything seems to
be fine
When the user closes the application instead after some amendments and a
printout or whatever and the next time a new doc is created via access,
I get an error in the Documents.Add(reVorlage) line
No, I don't have a reason for having one single line instead of two ... just
thought that would be a way around to get rid of that open line from my tool
to word underneath.
think I better stop this ... and do something else today!!!! before I go mad
;)
Gina
> Hi Gina,
>
[quoted text clipped - 103 lines]
> > > > Please anyone an idea of what this could be??
> > > > Gina