
Help -- Background Print Word file using automation fails
Hi Ken,
Once you've instantiated a new Word application object through the New
keyword, you don't need another Set statement. VBA doesn't create the
object right away when you declare the variable using the New keyword, but
it will automatically load the server when it comes across a line of code
which references the server, in your case, wrd.visible=True.
Either try removing the Set statement in your code, or to be more explicit
in your code, try something like this
DIm wrd as Word.Application
set wrd=New Word.Application
Also, since you basically want to wait till the print job has finished, why
not disable the background print option? I think Printout method has an
optional param
wrd.ActiveDocument.Print Background:=False
or close to it.
HTH
-- Dev
Quote:
>My function has the following code:
>Sub PrintDocument()
> Dim wrd As New Word.Application
> Set wrd = Word.Application
> wrd.Visible = True ' Not necessary
> wrd.Documents.Open Filename:="C:\Lease2K\Lease2K.DOC"
> wrd.ActiveDocument.PrintOut
> Do While wrd.BackgroundPrintingStatus <> 0
> DoEvents ' Let Word print the document
> Loop
> wrd.Quit
>End Sub
>The line Set wrd = Word.Application fails and Access reports the following:
>ActiveX component can't create object or return reference to this object
>(Error 429)
>and the help file reports this introductory line ... Creating objects
>requires that the object's class be registered in the system registry and
>that any associated dynamic-link libraries (DLL) be available. This error
>has the following causes and solutions: ....
>Microsoft Word Object 8.0 Library is checked in Access' Tools/References
>list.
>I'm running Win 98 and OfficePro-SR2, full installs of each.
>Any one have any idea what I need to do?
>Thanks -- Ken