• Error opening form (MS Office 2003)

    Author
    Topic
    #424329

    Hi,

    We just upgraded to Office 2003 and I’m trying to create a simple (well, not so simple, but the idea of it is basic) document with a single form. The following is the code that opens my form from a toolbar button:

    Sub showMyForm()
    Load frmUpdate
    frmUpdate.Show
    End Sub

    For some odd reason, I periodically get runtime error 5825 (Object has been deleted). The de###### highlights the Load line. The form is there, though, hasn’t been moved since the second before when it opened properly. Usually saving and re-opening the template will get rid of the error, but this time it doesn’t seem to want to.

    Has anyone seen this before? Is it new to 2003? How do I fix it?

    Viewing 0 reply threads
    Author
    Replies
    • #974138

      You don’t really need the line Load frmUpdate, for the Show method will load it if needed.

      Do you have code in the Initialize event of frmUpdate? If so, what code?

      • #974141

        As always, Hans to my rescue!

        Just after I posted this, I realized that it was the initialize event that was actually causing the error (although it stops on the load line. grrrr). Here’s the code:

        Private Sub UserForm_Initialize()
        On Error GoTo HandleError

        Me.txtAcctNum.Text = ActiveDocument.Variables(“AcctNum”).Value

        Exit Sub
        HandleError:
        Select Case Err.Number
        Case Else
        MsgBox Err.Number & ” ” & Err.Description
        End Select

        End Sub

        Keep in mind that I added the error handling a few minutes ago to verify that this was actually causing the error. But I still haven’t a clue what the problem is, as the variable “AcctNum” is still in the active document, and it still contains data. When I added the error handling to this, I was able to proceed, and the rest of my variables appear to be behaving, none of them give me an object deleted error. Deleting the variable and putting it back in does not help one bit.

        Sooo confusing!!!

        • #974147

          Sometimes, Word gets confused over what the ActiveDocument is. Does it work if you replace ActiveDocument with ThisDocument?

          • #974151

            ThisDocument doesn’t help. It still thinks that that variable isn’t there. But it really is there!!!

            Grrrrrrrrr. confused

            • #974156

              Sorry, can’t explain that. If you like, you can attach a stripped down copy of the document (remove sensitive information, zip it if necessary). Perhaps someone with Word 2003 (I’m still on 2002) will have a suggestion.

            • #974323

              Funny feeling it’s a bug. The way I was able to get around it was to write code to delete and re-create the same docvariable. Of course it couldn’t delete it, and creating it didn’t really do anything, but now the variable is recognized. Strange.

              Thanks for your help, as always, Hans!

    Viewing 0 reply threads
    Reply To: Error opening form (MS Office 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: