Showing posts with label word. Show all posts
Showing posts with label word. Show all posts

Monday, March 26, 2012

please help

hi i am using a word application to get data from a word file, i use the following code to open the word application and document:

Dim objWord As New Word.Application
Dim docNew As New Word.Document

and i am using the following code to close and quit the applications:

'Close the Automation object
objWord.Quit()
' Cleanup the unmanaged objects
System.Runtime.InteropServices.Marshal.ReleaseComObject(objWord)

but when i look at the processes in my task manager winword.exe with username asp.net never ends, and the more i run the application, the more winword.exe's that open. Am i trying to close it wrong?
thanks in advance for any help!I'm not familiar with using word with ASP.NET, but after you release the object you should set it = nothing. This marks the object for garbage collection and allows the object to be destroyed.
You need to do:

docNew.Close(Word.wdSaveOptions.wdDoNotSaveChanges)
Marshal.ReleaseComObject(docNew)
docNew = nothing

objWord.Quit(Word.wdSaveOptions.wdDoNotSaveChanges)
Marshal.ReleaseComObject(objWord)
objWord = nothing

Brian
Thanks a million, that works perfectly! thanks for your help!

Please Help

hello

wondered if anyone could give me a bit of advice on asp.net.

im coding a site using vb.net. that uploads word and pdf documents to a location which can then be viewed and downloaded if requried,

what iv got is an sql database that holds all the details that the user enters into the forms along with the actual file, e.g title, author, date etc, and it all works fine! originally i uploaded the file into the database but it wasnt working properly so instead of the actual file, i was just gonna use the file location in the appropriate sql table. e.g documents\test.doc

so what i need to be able to do is upload the selected .doc or .pdf file to a folder called documents\ on the same location as the upload.aspx webpage!

im guessing some sort of ftp command in the code or somethin? seems so easy in theory but i cant get my head round how to do it. any ideas would be great!

Cheerstake a look at the HtmlInputFile control and the System.IO namespace in the framework.

Its relatively simple and there are many articles.