Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error opening form (MS Office 2003)

    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?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error opening form (MS Office 2003)

    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?

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error opening form (MS Office 2003)

    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!!!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error opening form (MS Office 2003)

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

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error opening form (MS Office 2003)

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

    Grrrrrrrrr. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error opening form (MS Office 2003)

    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.

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error opening form (MS Office 2003)

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •