none
Error -2147417851 Method '~' of object '~' failed in VB6 with word 2003 RRS feed

  • Question

  • We have very strange error here for which we could not find any solution. I hope VB6 ,word expert could help us in this.

    We have our code in VB6. There is a functionality in the code in which we send the word documents to client/users through the code. Word documnets have bookmarks in them. During send operation code creates word object, generates the bookmarks in the ActiveDocument and send it to client.

    However, users are getting below error while sending the documents. We have tried tried users scenarios in our local machines the error does not get reproduced. Below is the error description through the log for the user.

    Error Description -2147417851 Method '~' of object '~' failed

    Source     RevisionDLL     CGCDocWordApp:ActiveBookmarkSet Method
    RevisionDLL     CGCDocWordApp:GetNextTypeBookmark Method
    RevisionDLL     IDocument:GenerateDocument Method
    DistribDll     IDistribution::PrepareDoc

    Note: The error occuring when the documents are in bunch. and the error is inconsistent. We checked the MDAC version of all servers. MDAC version are matching

    Which googled around for all possible solutions but neither solution is working for us.

    Monday, February 9, 2015 11:35 AM

Answers

  • Hi Soha Sayed

    As the article Caillen points to explains, Word was not designed to be used the manner you describe. If this is only happening when mutliple documents are being processed it's likely that some kind of conflict is occurring in the Word application in the server environment. It's unlikely you'll be able to resolve the problem if you need to produce these documents server-side.

    My recommendation would be that you convert the document/template you're using to the OpenXML file format (*.docx) and then rewrite the current code to work directly with the Open XML file, rather than automating the Word application. The Open XML file formats were designed expressly for server-side document manipulation scenarios. Execution will be much faster and you won't have to contend with the unsupported Word application running in a server environment.

    Note that Word 2000, 2002 and 2003 can open an Open XML file if the conversion package (installed with automatic updates or can be downloaded and installed) is present.

    If you need to stick with VB6 then you'll need tools that can unzip/zip an Open XML document "package" as well as tools to work with the internal XML. You'll find more information on the file format and working with "packages" at OpenXMLDeveloper.org

    More comfortable would be to work with the Open XML SDK in VB.NET or C#, just FYI :-)


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, February 12, 2015 8:04 PM
    Moderator

All replies

  • Hi soha,

    It seems that you automate the Word application on the server side, I recommend that you firstly take a look at this consideration from Microsoft:

    Considerations for server-side Automation of Office

    Besides I want to confirm with you about these things:

    1. Did this happen to only one user or to all the users? If it's only for a specified user, is there any difference between that Word document and others'?

    2. Is the error thrown on the client side or server side?

    3. Could you please post the code that throws the error here?


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 10, 2015 10:13 AM
    Moderator
  • Hi ,

    Thank you for your reply.

    I will gather all this information and get back to you for sure.  Thank you so much in advance.

    Tuesday, February 10, 2015 3:03 PM
  • Hi Caillen,

    1. It hapen to any user randomly. It is not for perticuler user/users.

    2. Error is thrown at server side.

    3. Below is the code shown in the error desciption.

    Public Sub ActiveBookmarkSet(iIndex As Integer, Optional szBookmark As String = "")
        On Error GoTo ActiveBookmarkSetErr
        Dim iErrorTimes As Integer

        iErrorTimes = 0
        If Not moBookmarks Is Nothing Then
            If iIndex > 0 Then
                If miActiveBookmarkCount >= iIndex Then
                    Set moBookmark = moBookmarks.Item(iIndex)
                    mszActiveBookmark = moBookmark
                End If
            ElseIf szBookmark <> "" Then
                If moBookmarks.Exists(szBookmark) = True Then
                    Set moBookmark = moBookmarks.Item(szBookmark)
                    mszActiveBookmark = moBookmark
                End If
            End If
        Else
            mobjRevision.objError.RaiseError CWORDERR_BASE_NoActiveBookmarks, App.EXEName & "::CGCDocWordApp::ActiveBookmarkSet", ""
        End If
        Exit Sub
    ActiveBookmarkSetErr:
        iErrorTimes = iErrorTimes + 1
        If iErrorTimes < 6 Then
            Resume
        End If

    "")
        Call mobjRevision.objError.RaiseError(Err, App.EXEName & "::CGCDocWordApp:ActiveBookmarkSet Method", Err.Description)
       
    End Sub

    Wednesday, February 11, 2015 8:34 AM
  • Please note that my application is windows based application running on Citrix server.

    Wednesday, February 11, 2015 11:55 AM
  • Hi Soha Sayed

    As the article Caillen points to explains, Word was not designed to be used the manner you describe. If this is only happening when mutliple documents are being processed it's likely that some kind of conflict is occurring in the Word application in the server environment. It's unlikely you'll be able to resolve the problem if you need to produce these documents server-side.

    My recommendation would be that you convert the document/template you're using to the OpenXML file format (*.docx) and then rewrite the current code to work directly with the Open XML file, rather than automating the Word application. The Open XML file formats were designed expressly for server-side document manipulation scenarios. Execution will be much faster and you won't have to contend with the unsupported Word application running in a server environment.

    Note that Word 2000, 2002 and 2003 can open an Open XML file if the conversion package (installed with automatic updates or can be downloaded and installed) is present.

    If you need to stick with VB6 then you'll need tools that can unzip/zip an Open XML document "package" as well as tools to work with the internal XML. You'll find more information on the file format and working with "packages" at OpenXMLDeveloper.org

    More comfortable would be to work with the Open XML SDK in VB.NET or C#, just FYI :-)


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, February 12, 2015 8:04 PM
    Moderator