[Word2003] Strange behaviour of .ListIndex

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15660
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

[Word2003] Strange behaviour of .ListIndex

Post by ChrisGreaves »

This is not critical, but it puzzles me.
My [ost]R[ecently][Use[d] application has been around for at least twelve years, and the basic concept - MRUse presents a drop-down list to the user, the user clicks on a file, and MRUse opens that file - has been working very well.
Untitled.png
In the example shown above I would like to open the Calendar.doc from T:\Blotter\, but only on the first use of the toolbar MRUse returns the first item on the listbox - the file Concordance.059.

I have issued logging statements to track this.
I load MSWord[2003] and regardless of which file I select, the logging on that first attempt always reports .ListIndex as being set to one - which is why, on the first attempt, I always open Concordance.059.
With Concordance.059 open, I immediately re-select my file Calendar.doc, and MRUse opens Calendar.doc

All subsequent uses of the listbox in the current MSWord session have the desired result - the .ListIndex has the correct value and the desired file is opened.
Only on the first use of the listbox after loading MSWord am I forced to open Concordance.059 and then re-select the desired file.

I will insert here the traditional disclaimer "I haven't changed anything related to the listbox"

If anyone can suggest a .ListIndex trick to sample the index and then discard it and re-sample it, I will give that a try.
If anyone wants to try running MRUse I can supply a copy and identify a suitable break-point in the code.

Thanks for any suggestions.
Chris :scratch:
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.

User avatar
HansV
Administrator
Posts: 78665
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: [Word2003] Strange behaviour of .ListIndex

Post by HansV »

Most Loungers won't have a menu/toolbar based version of Word anymore, so I think you'll have to attach a copy (stripped down and zipped).
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15660
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: [Word2003] Strange behaviour of .ListIndex

Post by ChrisGreaves »

HansV wrote:
19 Jul 2022, 14:26
Most Loungers won't have a menu/toolbar based version of Word anymore, so I think you'll have to attach a copy (stripped down and zipped).
Thanks Hans.
I should be doing a stripped-down version anyway, to isolate the problem area. After all, if I can produce a stripped-down version from 2,661 lines of code, the act of producing the stripped-down version may well reveal define the problem!
Cheers, Chris
He who plants a seed, plants life.

User avatar
Jay Freedman
Microsoft MVP
Posts: 1320
Joined: 24 May 2013, 15:33
Location: Warminster, PA

Re: [Word2003] Strange behaviour of .ListIndex

Post by Jay Freedman »

Chris, I have Word 2003 running in a virtual machine. If you post MRUse (as a .dot file or exported to .bas/.frm files) somewhere like Dropbox and give me a download link, I'll examine the code to try to find out why it's misbehaving and what can be done to fix it.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15660
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: [Word2003] Strange behaviour of .ListIndex

Post by ChrisGreaves »

Jay Freedman wrote:
22 Jul 2022, 17:07
Chris, I have Word 2003 running in a virtual machine. If you post MRUse (as a .dot file or exported to .bas/.frm files) somewhere like Dropbox and give me a download link, I'll examine the code to try to find out why it's misbehaving and what can be done to fix it.
Thank you for this kind offer, Jay.
A PKZip file is available as www.chrisgreaves.com/Downloads/20220723_1921.zip.

"Please do not spend a lot of time on this; I am making time to do what I should have done weeks ago - stripping the code down to the bare minimum to demonstrate the flaw."

Thanks, Chris
He who plants a seed, plants life.

User avatar
DocAElstein
5StarLounger
Posts: 621
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: [Word2003] Strange behaviour of .ListIndex

Post by DocAElstein »

Hi Chris
As you probably know, I have a few versions of Office 2003 on different computers, old and new. But as you know I am stupid and slow to get the point, - I don’t have a clue what you are doing here and just now don’t have the time to try and find out.
But if its any use and you have time and want to give crystal clear simple steps , idiot proof, for me to follow, then I can try out anything for you, and let you know what happens, maybe in a day or so, when I am near all my computers.

Alan
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

User avatar
Jay Freedman
Microsoft MVP
Posts: 1320
Joined: 24 May 2013, 15:33
Location: Warminster, PA

Re: [Word2003] Strange behaviour of .ListIndex

Post by Jay Freedman »

Hi Chris,

I'm not sure I'm seeing the same behavior you're seeing. When I open MRU.dot and the MRU toolbar first appears, it does have the first list item highlighted (for me, that's Normal.dot), but when I click any other document in the list, the chosen document does open -- in this case, it's .ListIndex = 15. If I understand your first post correctly, the (mis)behavior would have opened Normal.dot for me, but that doesn't happen.

One thing in the code confuses me. In modToolbar.MRUOpener, I see these statements:

Set NewItem = CommandBars(strMenubar).Controls(strMenubar & "D")
With NewItem
Dim strFullName As String
' Call UW.AMLog(ThisDocument, .ListIndex, True, True)
strFullName = CommandBars(strMenubar).Controls(strMenubar & "F").List(.ListIndex)


Both Controls(strMenubar & "D") and Controls(strMenubar & "F") are CommandBarComboBox objects, and they have different .ListIndex values, but I see only one combo box on the toolbar. What are they supposed to be, and how do they interact?

Cheers,
Jay