Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
someone
 
Posts: n/a
Default Slight problem automating Excel in a service

I hope someone can help me out here.

I'm using VB.Net and VS .Net 2003 to write code that automates Excel 2003.
Basically, a FileSystemWatcher object watches a folder and it's subfolders
if a user desires. If an Excel generated HTM files is output to the
folder(s), the FSW detects the creation of the file, loads it into Excel in
the background (visible = false), and prints out the document.

I wish I had a copy of the code to paste (forgot to bring some home with
me). Basically, I let the program thread sleep for 1 second (to ensure the
file is fully written out), I just create an Excel Workbook object in code,
add the HTM file to it to load it up, I print the document out, then I set
saved to true so I won't get a prompt asking me to save the file, then I
quit/close the application.

The code itself runs fine. I developed and tested the code in a desktop
application. I could run it, set the program to watch a folder, and
whenever such a file is written to the directory, Excel loads up in the
background, prints it out, and closes itself just fine.

Problem: I needed this code to run in a service so the files will always
print out because someone won't always be logged in. So, I created a
service and copied the code into the service. At first, it wouldn't work.
After debugging the service and looking at task manager, it appears Excel
starts up but for some reason hangs in the background. I noticed while
stepping through the code in the service it appears to stop at the line
where the file is being loaded into Excel and stays there until I shut down
the Excel program running in the background via task manager. Once I do
this, I get some sort of an error message I can't recall at the moment (the
code is inside a try...catch block). After reading up on services and such,
I decided to set the account the service runs under from localsystem to
user. Once I do this, I get asked for a userid and password upon
installation of the service. Once I do this, I can start the service. Once
I do this, the service runs fine and does what it's supposed to i.e. it
prints out the document that's inserted into the specified directory. I
created an administrative account on the local machine and set the service
to this. Funny thing is, it wouldn't work using the admin account on the
machine. Same problem as before (Excel hanging in background upon load of
file into Excel). It seems to work fine when entering an admin account from
the Network/domain.

The code ran fine while in a program and it runs fine fine after I set the
service run account to user while entering a userid/password during the
service install. As such, I'm left to conclude there is some sort of a
security problem. Thing is, the service was initially set to run under the
localsystem account. I thought setting the service to this account type
would let it do anything, but apparently I was wrong. Any ideas on how to
fix this?

Thanks for any advice.

Chris Smith


  #2   Report Post  
Lee Gillie
 
Posts: n/a
Default

I have found it to work best with a privileged domain user. I have not
had problems automating office from a service, just in getting the
processes to go away when I am done with them.
  #3   Report Post  
someone
 
Posts: n/a
Default

Any idea why? It must be possible to do this. We have purchased a product
that creates Excel based reports for us. It doesn't use a Domain based
userid. Although I think we did have to create an administrative userid and
password but it was a new user on the machine, not the domain. Yet, this
process works fine as it's a service that runs as a Localsystem account.
There must be a way to do this. I just don't know how.

Thanks!

Chris Smith

"Lee Gillie" wrote in message
...
I have found it to work best with a privileged domain user. I have not had
problems automating office from a service, just in getting the processes to
go away when I am done with them.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Path\File name length problem Excel Crash on save as Datasort Excel Discussion (Misc queries) 0 April 8th 05 05:19 PM
Problem Editing Macro in Shared Excel File [email protected] Excel Discussion (Misc queries) 0 March 19th 05 06:01 PM
Excel problem with web based spreadsheets Steve Williams Excel Discussion (Misc queries) 0 January 12th 05 02:11 PM
Excel 97 chart opened in Excel 2003 - Source Data problem DHunt Charts and Charting in Excel 0 December 6th 04 08:05 PM
Staring Excel Problem Everton Excel Discussion (Misc queries) 1 November 26th 04 09:22 PM


All times are GMT +1. The time now is 04:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"