|
-
Jun 25th, 2004, 06:38 AM
#1
Thread Starter
Frenzied Member
Creating word documents in asp.net *RESOLVED*
I'm trying to create and write a word document within asp.net using:
Code:
Word.ApplicationClass WordApp = new Word.ApplicationClass();
Does anyone know of a reference for all the objects I can use in word?
DJ
Last edited by dj4uk; Jul 7th, 2004 at 05:11 AM.
-
Jun 25th, 2004, 01:18 PM
#2
Something like this:
PHP Code:
object objFileName = Server.MapPath("MyDocs") + "\\MyDocument.doc";
object missing = System.Reflection.Missing.Value;
Word.ApplicationClass objWord = new Word.ApplicationClass();
Word.Document objDoc = objWord.Documents.Add(ref missing, ref missing, ref missing, ref missing);
objDoc.Activate();
objWord.Selection.TypeText("This is my text");
objWord.Selection.TypeParagraph();
objDoc.SaveAs(ref objFileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
objDoc.Close(ref missing, ref missing, ref missing);
objWord.Application.Quit(ref missing, ref missing, ref missing);
-
Jun 28th, 2004, 03:30 AM
#3
Thread Starter
Frenzied Member
Thanks for that Serge - I'll give it a go.
Do I need any import or using statements?
DJ
-
Jun 29th, 2004, 10:37 AM
#4
You will need to add a reference to Microsoft Word library. Also you will have to change permissions for this library to be used through the web app by using dcomcnfg
-
Jun 29th, 2004, 10:46 AM
#5
Thread Starter
Frenzied Member
You don't happen to know where this Word library is stored? I'm guessing it probably a dll file.
DJ
-
Jun 29th, 2004, 01:29 PM
#6
Actually, its an ActiveX EXE. In your solution explorer right click on the refereces folder and select Add Reference. Then select COM tab and check Microsoft Word 8.0 (or any other version you have installed).
-
Jun 29th, 2004, 02:33 PM
#7
Thread Starter
Frenzied Member
I don't have Visual Studio .NET unfortunately (Billy Gates charges to much for humble me!) - could you let me know the path and name of the file.
Thanks very much for all your help - it's much appreciated!
DJ
-
Jul 2nd, 2004, 12:40 PM
#8
Usually it's in:
C:\Program Files\Microsoft Office\Office\WinWord.EXE
-
Jul 6th, 2004, 02:31 PM
#9
Frenzied Member
Actually, you can't reference an EXE.
The file is an object library:
C:\Program Files\Microsoft Office\Office\MSWord*.olb
where * is 8 for Word97 or 9 for Word 2000
-
Jul 7th, 2004, 03:08 AM
#10
Thread Starter
Frenzied Member
In the end I found a better way - downloading the primary interop assemblies (PIAs) from Microsoft.
Thanks for all your help tho'.
Anyone know of a good online resource for the word document model?
Cheers
DJ
-
Jul 7th, 2004, 05:11 AM
#11
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|