rita Posted April 1, 2004 Posted April 1, 2004 When I am saving a file on my server using asp.net application, it gives me "Access Denied", but I don't have the case on my localhost server. knowing that I gave all users full permissions. I use the word.application to save my file. Dim WordApp As Word.ApplicationClass = New Word.ApplicationClass() Dim aDoc1 As New Word.Document() aDoc1.Activate() aDoc1.Content.Text = FileContent aDoc1.SaveAs(fileURL) WordApp.Quit() aDoc1 = Nothing WordApp = Nothing any help please. Thanks in advance. Quote
Arch4ngel Posted April 1, 2004 Posted April 1, 2004 Can I have the content of the variable fileURL ? Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
rita Posted April 1, 2004 Author Posted April 1, 2004 the FileURL contains the physical directory for the file. ex: c:/folderName/fileName.doc Quote
Administrators PlausiblyDamp Posted April 1, 2004 Administrators Posted April 1, 2004 Does the ASPNET account on the server have permissions to this folder? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
rita Posted April 1, 2004 Author Posted April 1, 2004 yes the ASPNET accounts have full access on this folder. Quote
Arch4ngel Posted April 1, 2004 Posted April 1, 2004 (edited) Function called ??? First ... make sure the file isn't already open by another Word. If you don't deallocate memory from Word objects, Word won't close correctly and will still have your document opened if you haven't closed it. Here is the function the clear them from memory. Private Sub Nars(o as Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject(o) Catch Finally o = nothing End Sub Edited April 1, 2004 by Arch4ngel Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Arch4ngel Posted April 1, 2004 Posted April 1, 2004 In your exemple, you must do : NAR(aDoc) before quitting or it won't close. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
rita Posted April 5, 2004 Author Posted April 5, 2004 I try what you suggested but I have the same error. Quote
Administrators PlausiblyDamp Posted April 5, 2004 Administrators Posted April 5, 2004 Which line of code actually generates the error? It may be a problem instantiating an instance of word.exe. I think you will need to grant permissions for aspnet to launch the application. If you are running XP (and I think win2k and win2003) this should work. Start->Run->dcomcnfg - this should launch the component services tool. Drill down to the correct computer and select DCOM config. Look for the package that corresponds to MS Word (think it is called either 'Microsoft Document' or 'Microsoft Word Document'). Right click on it and bring up the property pages, then go to the security tab. Under launch permissions select customize and then edit. Finally add in the \ASPNET account. Not 100% on all of the above (don't have word or VS installed here) but it should be close enough to get you looking in the right direction. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
rita Posted April 7, 2004 Author Posted April 7, 2004 I do what you suggested but nothing happen. I want to inform you that when I used the streamwriter to save the file, everything is fine and no "access denied " error. But I cannot use it because streamwriter doesn't allow me to customize my document (font family etc.....). So what I thing that is a problem between word and the MyServerName\ASPNET account. what do you suggested? thanks in advance. Quote
Administrators PlausiblyDamp Posted April 7, 2004 Administrators Posted April 7, 2004 The only thing I can think of is a dcom permission - if you have allowed the aspnet account launch permissions to word it should work. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
rita Posted April 7, 2004 Author Posted April 7, 2004 I receive this error: "QueryInterface for interface Word._Document failed" any suggestion? Quote
Administrators PlausiblyDamp Posted April 7, 2004 Administrators Posted April 7, 2004 Quick search on google only brought back one hit - may be worth having a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnofftalk/html/office10032002.asp Out of interest does the server have the same version of word as your development box? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Liqdfire Posted April 14, 2004 Posted April 14, 2004 Even though the aspnet account has write rights you still need the IUSR_<machinename> to have write rights to the directory. You might even try impersonation that allows the app to run inthe same user context as the account its impersonating instead of the asp app domain. Also did you change your machine.config to reflect the system process type to system instead of machine ?? C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\CONFIG\machine.config ie <processModel enable="true" timeout="Infinite" idleTimeout="Infinite" shutdownTimeout="0:00:05" requestLimit="Infinite" requestQueueLimit="5000" restartQueueLimit="10" memoryLimit="60" webGarden="false" cpuMask="0xffffffff" [color=Red]userName="machine"[/color] password="AutoGenerate" logLevel="Errors" clientConnectedCheck="0:00:05" comAuthenticationLevel="Connect" comImpersonationLevel="Impersonate" responseRestartDeadlockInterval="00:09:00" responseDeadlockInterval="00:03:00" maxWorkerThreads="25" maxIoThreads="25" /> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.