DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 22 Aug 2007 11:14:27 -0700,    posted on: microsoft.public.dotnet.languages.vb        back       

Thread Index
  1    unknown
          2    AMDRIT
          3    kelphis


printing word doc from windows service   
I have been doing alot of looking around for a way to use the
Microsoft.Office.Interop classes to print word documents.  It is very
easy to do from a normal windows application but it does not work from
a windows service.

The following line causes the service to hang.

Dim wordapp As Word.Application = New Word.Application

I dont even have a chance to turn of the UI stuff.  Does anyone have
any idea how to use this stuff in a service?  I would really
appreciate it.
Date:Wed, 22 Aug 2007 11:14:27 -0700   Author:  

Re: printing word doc from windows service   
Something that I have found, at least back when it was NT 4.0 was that if 
the user did not log in interactively, the printer hive of the current user 
in the registry was not populated.

At the time, the work around that we implemented was to have a dedicated 
server always logged in with appropriate credentials and act as a print 
queue server.  We then simply asked this sever to process the documents and 
notify the requestor (Web service, web application, windows application) 
when the job was done.  Sometimes, for long running reports, we just had the 
server email the reports to the requestor.

Since then, the company dumped the code into a windows service.  This 
allowed us to not have a server logged into all the time, but we did leave 
the report queue on a dedicated server and had the web services/windows 
applications request the reports.  The windows service must log in with 
valid credentials and the account must be allowed to log in interactively (I 
don't recall if we need to act as part of the OS as well).

I wonder if your issue is related to the issue we had.

Other things to check:

Does the windows service machine have MS Word (Professional or better 
installed 2k+)
Does the windows service have the MS Office .Net Interop assemblies 
installed

if yes to those, can you create the word application with createobject?

Dim objWordApp as object = createobject("Word.Application")
dim objWordDoc as object = objWordApp.Documents.Add...
when creating objects with createobject it is prolly best to release them as 
thus:

objWordDoc.Close(save:=false)
objWordApp.Quit

 'http://support.microsoft.com/kb/317109
System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordApp)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDoc)


HTH

 wrote in message 
news:1187806467.221992.93540@r23g2000prd.googlegroups.com...

>I have been doing alot of looking around for a way to use the
> Microsoft.Office.Interop classes to print word documents.  It is very
> easy to do from a normal windows application but it does not work from
> a windows service.
>
> The following line causes the service to hang.
>
> Dim wordapp As Word.Application = New Word.Application
>
> I dont even have a chance to turn of the UI stuff.  Does anyone have
> any idea how to use this stuff in a service?  I would really
> appreciate it.
> 
Date:Wed, 22 Aug 2007 16:18:38 -0500   Author:  

Re: printing word doc from windows service   
On Aug 22, 4:18 pm, "AMDRIT"  wrote:

> Something that I have found, at least back when it was NT 4.0 was that if
> the user did not log in interactively, the printer hive of the current user
> in the registry was not populated.
>
> At the time, the work around that we implemented was to have a dedicated
> server always logged in with appropriate credentials and act as a print
> queue server.  We then simply asked this sever to process the documents and
> notify the requestor (Web service, web application, windows application)
> when the job was done.  Sometimes, for long running reports, we just had the
> server email the reports to the requestor.
>
> Since then, the company dumped the code into a windows service.  This
> allowed us to not have a server logged into all the time, but we did leave
> the report queue on a dedicated server and had the web services/windows
> applications request the reports.  The windows service must log in with
> valid credentials and the account must be allowed to log in interactively (I
> don't recall if we need to act as part of the OS as well).
>
> I wonder if your issue is related to the issue we had.
>
> Other things to check:
>
> Does the windows service machine have MS Word (Professional or better
> installed 2k+)
> Does the windows service have the MS Office .Net Interop assemblies
> installed
>
> if yes to those, can you create the word application with createobject?
>
> Dim objWordApp as object = createobject("Word.Application")
> dim objWordDoc as object = objWordApp.Documents.Add...
> when creating objects with createobject it is prolly best to release them as
> thus:
>
> objWordDoc.Close(save:=false)
> objWordApp.Quit
>
>  'http://support.microsoft.com/kb/317109
> System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordApp)
> System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDoc)
>
> HTH
>
>  wrote in message
>
> news:1187806467.221992.93540@r23g2000prd.googlegroups.com...
>
>
>
> >I have been doing alot of looking around for a way to use the
> > Microsoft.Office.Interop classes to print word documents.  It is very
> > easy to do from a normal windows application but it does not work from
> > a windows service.
>
> > The following line causes the service to hang.
>
> > Dim wordapp As Word.Application = New Word.Application
>
> > I dont even have a chance to turn of the UI stuff.  Does anyone have
> > any idea how to use this stuff in a service?  I would really
> > appreciate it.- Hide quoted text -
>
> - Show quoted text -


Thank you so much for the reply.  I tried what you suggested but it
did not work.  I really think that the problem is with the GUI that
the word.application object wants to use.  If I try to open a windows
form from a service the same thing happens.  Is there a way around
this.  There is a way to turn the UI off but i cant do that until an
object instance is created.  I would hope that there is another word
object that can be used.  all I need to do is print.  I dont care
about anything else.

I have thought of some other possibilites.  If i could convert the DOC
into a PDF then I could Convert the PDF into a bitmap and images are
easily printed but im having trouble finding a Doc to PDF converter
that my service can hook into.
Date:Thu, 23 Aug 2007 07:19:41 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us