Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Runtime error 5825 Object has been deleted?

502 views
Skip to first unread message

Jezebel

unread,
Sep 2, 2006, 11:44:38 PM9/2/06
to
You'll need to post some details. Don't post attachments: the security risk
in opening them is too great.

"Joacim" <Joa...@microsoft.com> wrote in message
news:u7c5jUwz...@TK2MSFTNGP02.phx.gbl...
> What am I doing wrong please? I thought it would list all autotext in
> label using listbox as name of autotext?
>
>
>
>


Joacim

unread,
Sep 3, 2006, 12:34:07 AM9/3/06
to
Thanks Jezebel,

It could be the way I set the userform - but seemed simple enough

VERSION 5.00

Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} UserForm

Caption = "UserForm"

ClientHeight = 9990

ClientLeft = 45

ClientTop = 435

ClientWidth = 17385

OleObjectBlob = "UserForm.frx":0000

StartUpPosition = 1 'CenterOwner

End

Attribute VB_Name = "UserForm"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Option Explicit

Dim oEntryName() As String

Dim oEntryValue() As String

Dim oEntryTemplate() As String

Dim oTemplate As Template

Dim oEntry As AutoTextEntry

Dim Counter As Integer

Private Sub UserForm_Initialize()

ReDim oEntryName(500)

ReDim oEntryValue(500)

ReDim oEntryTemplate(500)

'-------------------------------------------

'Get all autotext entries that are *not* in normal template into an array

For Each oTemplate In Templates

For Each oEntry In oTemplate.AutoTextEntries

Select Case oTemplate.Type

Case wdNormalTemplate

Case Else

oEntryName(Counter) = oEntry.Name

oEntryValue(Counter) = oEntry.Value

oEntryTemplate(Counter) = oTemplate.FullName

Counter = Counter + 1

End Select

Next oEntry

Next oTemplate

'-------------------------------------------

ReDim Preserve oEntryName(Counter - 1)

ReDim Preserve oEntryValue(Counter - 1)

ReDim Preserve oEntryTemplate(Counter - 1)

ListBox1.List = oEntryName

ListBox1.ListIndex = 0

End Sub

Public Sub Listbox1_Change()

Label1.Caption = oEntryValue(ListBox1.ListIndex)

End Sub

Jezebel

unread,
Sep 3, 2006, 1:13:48 AM9/3/06
to
What line throws the error?

"Joacim" <Joa...@microsoft.com> wrote in message

news:ejgCyIxz...@TK2MSFTNGP02.phx.gbl...

Joacim

unread,
Sep 3, 2006, 1:31:01 AM9/3/06
to
That's the problem the error just sits in Visual Basic on the Userform.

Userform
Listbox1
Label1 (Text)

That's it - I posted code behind Userform - I must be doing something wrong
on user form?

"Jezebel" <warc...@whitehouse.gov> wrote in message
news:%23mmy8ex...@TK2MSFTNGP06.phx.gbl...

Russ

unread,
Sep 3, 2006, 2:00:10 AM9/3/06
to
Joacim,

When the error message dialog box pops up, isn't there a 'Debug' button you
can press in that dialog box to get VBA to highlight the line in the code
that produced the error? If so, what is the code line it is complaining
about. Or is this VB code and not VBA code?

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Joacim

unread,
Sep 3, 2006, 2:06:49 AM9/3/06
to
No it was HELP and my VB help is not connectingt. I am rebooting to see if
that helps. I may have got caught in a break mode.

But the code still does not work but I might get the DEBUG option.

Will let you know in about 10 minutes. Tks for helping me.

"Russ" <drsN0SP...@hotmailD0Tcom.INVALID> wrote in message
news:C11FE7AA.123BC%drsN0SP...@hotmailD0Tcom.INVALID...

Joacim

unread,
Sep 3, 2006, 2:14:43 AM9/3/06
to
I just rebooted and this is same error: Yes I realise VBA gives me DEBUG
normally but this is not so.

---------------------------

Microsoft Visual Basic

---------------------------

Run-time error '5825':

Object has been deleted.

---------------------------

OK Help

--------------------------

"Russ" <drsN0SP...@hotmailD0Tcom.INVALID> wrote in message
news:C11FE7AA.123BC%drsN0SP...@hotmailD0Tcom.INVALID...

Doug Robbins - Word MVP

unread,
Sep 3, 2006, 2:28:47 AM9/3/06
to
You could try inseting a MsgBox into the code and moving it down one line of
code after each attempt until you get the error instead of the message box
and then the line before the MsgBox will be the (first) one that is causing
the error.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Russ" <drsN0SP...@hotmailD0Tcom.INVALID> wrote in message
news:C11FE7AA.123BC%drsN0SP...@hotmailD0Tcom.INVALID...

Russ

unread,
Sep 3, 2006, 2:30:31 AM9/3/06
to
Joacim,

Sorry I don't use a Visual Basic editor, I'm more familiar with Visual Basic
for Applications editor code.

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Russ

unread,
Sep 3, 2006, 2:36:40 AM9/3/06
to
Joacim,
Or does your editor have a debug menu to run the code in single step mode?
Then you can see which line produces the error.

> You could try inseting a MsgBox into the code and moving it down one line of
> code after each attempt until you get the error instead of the message box
> and then the line before the MsgBox will be the (first) one that is causing
> the error.

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Joacim

unread,
Sep 3, 2006, 2:35:20 AM9/3/06
to
Thank you - not today though. It looked good code but obviously something is
amiss.

Thanks for the assist everyone.
"Doug Robbins - Word MVP" <d...@REMOVECAPSmvps.org> wrote in message
news:O2jv4Iyz...@TK2MSFTNGP05.phx.gbl...

Joacim

unread,
Sep 3, 2006, 2:40:34 AM9/3/06
to
Yes, but on this code with the Userform Label1 and Listbox1 which was the
codes instructions to use it (from one of these groups - I waas snooping
around and thought it might come in hand).

Normal code I get Continue End Debug yes my editor does but this code does
not do it.
Don't worry - I'll come back to itl.


"Russ" <drsN0SP...@hotmailD0Tcom.INVALID> wrote in message

news:C11FF038.124D2%drsN0SP...@hotmailD0Tcom.INVALID...

Joacim

unread,
Sep 3, 2006, 2:44:41 AM9/3/06
to
Watch : : oEntryName : <Out of context> : Empty :
UserForm.UserForm_Initialize

Does that help?

"Russ" <drsN0SP...@hotmailD0Tcom.INVALID> wrote in message

news:C11FF038.124D2%drsN0SP...@hotmailD0Tcom.INVALID...

Russ

unread,
Sep 3, 2006, 2:47:23 AM9/3/06
to
Joacim,

You might be trying to run 'Visual Basic' code in a 'Visual Basic for
Applications' Editor. Visual Basic is not the same as Visual Basic for
Applications.

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Joacim

unread,
Sep 3, 2006, 2:51:18 AM9/3/06
to
I see - now I comprehend.... thank you...

"Russ" <drsN0SP...@hotmailD0Tcom.INVALID> wrote in message
news:C11FF2BB.124D8%drsN0SP...@hotmailD0Tcom.INVALID...

Russ

unread,
Sep 3, 2006, 2:52:32 AM9/3/06
to

Joacim,

> Watch : : oEntryName : <Out of context> : Empty :

A variable might show <Out of context> until it is set equal to some value
later in the subroutine. Are you using Option Explicit in the Declarations
section to expose any undeclared variables?

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Joacim

unread,
Sep 3, 2006, 3:08:14 AM9/3/06
to
Yes Option Explicit is at beginning of all my routines.

The Userform does not load - yet it is userform initialise.

My other userforms all load fine. Perhaps it is VB code I have not seen
reDim used in other VBA code I use.

"Russ" <drsN0SP...@hotmailD0Tcom.INVALID> wrote in message

news:C11FF3F0.124DB%drsN0SP...@hotmailD0Tcom.INVALID...

Jezebel

unread,
Sep 3, 2006, 3:13:25 AM9/3/06
to
Nothing wrong with Redim in VBA.

You can't load UserForms into a VB application.

"Joacim" <Joa...@microsoft.com> wrote in message

news:O4DI6ey...@TK2MSFTNGP03.phx.gbl...

Russ

unread,
Sep 3, 2006, 3:18:43 AM9/3/06
to
Joacim,

Redim is a legitimate statement in VBA. You should be able to look that up
in VBA Help.

These lines...
-----------------------------------
VERSION 5.00

Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} UserForm
------------------------------------
And
------------------------------------
Attribute VB_Name = "UserForm"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False
--------------------------------------

...look strange to me. I don't think VBA uses 'Attribute'

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Joacim

unread,
Sep 3, 2006, 4:01:28 AM9/3/06
to
Thanks everyone for the assist.

"Russ" <drsN0SP...@hotmailD0Tcom.INVALID> wrote in message
news:C11FFA13.124E2%drsN0SP...@hotmailD0Tcom.INVALID...
0 new messages