Script collapsing embedded, single category view in Notes client works only once

I have an embedded outline on a page in left frame of a frameset. Outline entries open pages in right frame. Each page has an embedded, single category, categorized view with @UserName as single category. I want to provide a button for users which collapses the embedded view to top visible level. The views never have more than 10 categories on that level.

I can’t use CollapseAll commands, because it makes everything disappear from the view. I guess it collapses to the single category, which is on top but not visible.

I know nothing of Windows API, but using tips from

Re: Collapse a categorized embedded View by default – Kwintessential Notes

I created a button with the following simple Lotusscript

For i =1 To 10

'Pressing subtract key to collapse category

keybd_event vKSubtract , 0, KeyDown, 0

keybd_event vKSubtract , 0, KeyUp, 0

'Pressing arrow down key to go to next category

keybd_event vKDown , 0, KeyDown, 0

keybd_event vKDown , 0, KeyUp, 0

Next

The button works fine - once!! If I expand all categories in the view, and try the button again, nothing happens. If I open another view page, and then go back to the first one, the button works again, but only once.

Using the physical keys ( - and +) on the keybord to collapse and expand levels works fine, again and again. There is nothing but the embedded view on the page, but somehow it seems to come out of focus for the script after using the button. And coming back to focus when I switch page and switch back again.

I have tried different tips on how to put focus on the embedded view, but without success.

Me and my users would very much like the button to work every time. Any help or hints with this would be much appreciated!

Subject: Script collapsing embedded, single category view in Notes client works only once

Hey Peter, just a guess but what if you do a Call notesUIView.SelectDocument( notesdocument ) at the end of your code? It may just retain the focus for you.

Subject: Solved: Script collapsing embedded, single category view in Notes client works only once

Thanks Luke, your suggestion helped me solve the problem! I tested it and happened then to discover my beginner’s mistake - I had placed the call to the script in the buttons Initialize event, instead of Click. (blushing)

When calling my keystroke script from the Click event, it works every time.

Subject: RE: Script collapsing embedded, single category view in Notes client works only once

Use CollapseAll, then refresh the view.