conversion of word to html through Microsoft office Library

conversion of word to html through Microsoft.Office.Interop.Word.ApplicationClass is working fine when i am running my website through visual studio, but when i run the same in the same website through IIS 7 , Conversion of word to html is not working ?
    I am calling a WebMethod for conversion of word to html through javascript. I have tested by putting OnSucess and OnFailure Function in javascript to check is it working or not .

Through Visual Studio - OnSucess function is executed
Through IIS  - OnFailure function is executed

Web Method
<System.Web.Services.WebMethod()> _
        <System.Web.Script.Services.ScriptMethod()> _
        Public Shared Function Convert(ByVal inputHtml As String) As String

            Dim objWord As Microsoft.Office.Interop.Word.ApplicationClass
            Dim doc As String = inputHtml
            Dim splitHtml As String() = doc.Split(New Char() {"/"c})
            Dim splitvalue As String
            splitvalue = splitHtml(splitHtml.Length - 3) + "\" + splitHtml(splitHtml.Length - 2) + "\" + splitHtml(splitHtml.Length - 1)
            Dim Splitcheck As String() = splitHtml(splitHtml.Length - 1).Split(New Char() {"."c})
            Dim path2Convert = System.Web.HttpContext.Current.Server.MapPath(".\" + splitHtml(splitHtml.Length - 3) + "\" + splitHtml(splitHtml.Length - 2) + "\" + Splitcheck(Splitcheck.Length - 2) + ".html")

            If (System.IO.File.Exists(path2Convert)) Then


                    Dim strWordDoc = inputHtml
                    Dim strHTMLDoc = path2Convert
                    objWord = CreateObject("Word.Application")
                    objWord.Visible = False
                    Dim FileFormat
                    Dim LockComments
                    Dim Password
                    Dim AddToRecentFiles
                    Dim WritePassword
                    Dim ReadOnlyRecommended
                    Dim EmbedTrueTypeFonts
                    Dim SaveNativePictureFormat
                    Dim SaveFormsData
                    Dim SaveAsAOCELetter
                    FileFormat = 8
                    LockComments = True
                    Password = ""
                    AddToRecentFiles = False
                    WritePassword = ""
                    ReadOnlyRecommended = False
                    EmbedTrueTypeFonts = False
                    SaveNativePictureFormat = True
                    SaveFormsData = False
                    SaveAsAOCELetter = False
                    objWord.ActiveDocument.SaveAs(strHTMLDoc, FileFormat, LockComments, Password, AddToRecentFiles, WritePassword, ReadOnlyRecommended, EmbedTrueTypeFonts, SaveNativePictureFormat, SaveFormsData, SaveAsAOCELetter)
                    objWord = Nothing

                Catch ex As Exception
                    'objWord = Nothing
                End Try
            End If

            Return inputHtml

        End Function

Javascript Code -

function AssignPath(strPath,strDocType,intDocId,strUploadId)
var PathSplit;
PathSplit = path.split('.');

if ((PathSplit[PathSplit.length - 1] == "doc") || (PathSplit[PathSplit.length - 1] == "docx")) {

     PageMethods.Convert(path, OnSucess, OnFailure);
     var output = path.substr(0, path.lastIndexOf('.'));
     path = output + ".html";

     function OnSucess(result) {

    function OnFailure() {

       alert("Conversion Failed");



Open in new window

Who is Participating?
depaaAuthor Commented:
We solved it in two different ways and i ma putting it here for the benefit of others.

Option 01. Since the application is a web based application and is trying to display a Microsoft word file in a web frame - we called Google doc to open the document for us in that frame. But, this solution will work as long as call to Google Doc  will work free or as long as they will not charge for this service.

Option 02. I am providing this with some reservations. Since I have got this solution from another Forum and I do not think that it is ethical to "Cut-copy-paste" solutions from one paid forum to another paid forum - I have the reservation.

Please check the following Link for the solution in the 2nd way - 

Hope this helps
Vadim RappCommented:
Almost certainly it's security-related issue, where IIS has less permissions than you. While it's hard to tell blindly what exactly is going on, I would look into (1) details of the exception raised by OnFailure, if any are available; then look in the event log, if there's anything generated at the time when this happens; then you can invoke audit policy /audit object access in Local security policy, and look at the events that will be generated.
depaaAuthor Commented:
We have solved this with advice from other experts
depaaAuthor Commented:
We waited for quite some time and did not get the help in time.

We solved it ourselves using one way and the other way was from advice from another forum.
Vadim RappCommented:
It's good that the author has solved the problem; however, I would like to note that the solution they found really isn't a solution of the problem that was in place here; it's in fact abandoning the original solution and implementing totally different one.

The mere fact that this code was already working in Visual Studio, means that it could be done; Visual Studio creates its own webserver, and the only difference between this webserver and IIS is in the credentials it runs under. With Word, it's quite obvious that if IIS is running under another credential than the user, there could be issues with Word not running on that credential "out of the box", same as it wouldn't run for another user, and might require an installation. Or even if it did run, this might be an issue as trivial as Word on the first launch showing modal dialog box requiring the user to enter the initials - maybe Word "showed" it to IIS. In any case, since the solution already worked on credential A and the matter was to port it to credential B, the most straightforward was to find out the difference between A and B and eliminate it. As a last resort, to try to run IIS with user's credential and allowing the service to interact with the desktop.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.