"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?
>
>
>
>
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
"Joacim" <Joa...@microsoft.com> wrote in message
news:ejgCyIxz...@TK2MSFTNGP02.phx.gbl...
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...
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
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...
---------------------------
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...
--
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...
Sorry I don't use a Visual Basic editor, I'm more familiar with Visual Basic
for Applications editor code.
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
> 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
Thanks for the assist everyone.
"Doug Robbins - Word MVP" <d...@REMOVECAPSmvps.org> wrote in message
news:O2jv4Iyz...@TK2MSFTNGP05.phx.gbl...
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...
Does that help?
"Russ" <drsN0SP...@hotmailD0Tcom.INVALID> wrote in message
news:C11FF038.124D2%drsN0SP...@hotmailD0Tcom.INVALID...
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
> 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
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...
You can't load UserForms into a VB application.
"Joacim" <Joa...@microsoft.com> wrote in message
news:O4DI6ey...@TK2MSFTNGP03.phx.gbl...
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