Click here to Skip to main content
16,020,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using word interop on an intranet environment (asp.net - c# code) to create a bunch of documents from templates. Anonymous login is disabled and security is set to integrated windows authentication

I want to use a service account to create a word doc. Once the document is created, the user is redirected to the document (to open it).

How do I do this?
There does not seem to be an option to pass a set of credentials.

This is the code I am using to create a new document. oTemplatePath is the path to the template.dot file
using Word = Microsoft.Office.Interop.Word;

Word.Application oWord = new Word.Application();
Word.Document oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);


I found the answer here[^]

A nice little impersonation class written by Uwe Keim[^]
Posted
Updated 19-Apr-10 19:31pm
v2

1 solution

RCoate wrote:
How do I do this?
There does not seem to be an option to pass a set of credentials.

Aye, there isn't such option. Alternatively, you can try to launch[^] your application under a different user and do the Word-thing from there.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900