Hi Helmut,
Thanks for your explanation. I thought the command was "DoEvent" and
tried to find that. Now I get it.
Sadly, it does not help. Nor does your complementary advice, at least
if I got it right (see below*).
Perhaps I did not explain correctly.
If I start Word, open a new document on the template with the macro
and then run the macro, the selection in the else clause will never be
executed.
If I start Word, open a new document on the template with the macro
but then (just) open the macro editor before I run the macro, the
selection in the else clause will not be executed the first time it
should, but after that as it is intended.
If I then close the editor again, the selection will be executed as it
should one more time, but after that not any more.
==============
I think I will let this case rest for now and perhaps next weekend try
to more systematically trace the flow in the macro and hopefully come
back then.
TIA
Örjan
*
If förstaGången Then
With comboInled
.SetFocus
.SelStart = 0
.SelLength = 100
End With
Else
With comboPatNr
.SetFocus
.SelStart = 0
.SelLength = 10
End With
Dim x
x = 1000
For i = 1 To x
DoEvents
Sleep 1000
Next
Btw, does the macro execution wait for the "sleep" to be finished? I
have the feeling it does not.
>Hi Örjan,
>doevents is nothing specific, just see help for "doevents".
[quoted text clipped - 12 lines]
>Word XP, Win 98
>http://word.mvps.org/
Helmut Weber - 14 Nov 2004 12:39 GMT
Hi Örjan,
to let a problem rest for a while, is a good idea.
Helped me a lot.
Besides of some lines, which I don't understand:
>x = 1000
>For i = 1 To x
> DoEvents
> Sleep 1000
>Next
would cause a timeout of 1000 seconds!
x = 1000, sleep 1000 (= 1000 milliseconds = 1 second)
= 1000 seconds
---
BTW, where are you from?
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
?rjan Skogl?sa - 14 Nov 2004 16:25 GMT
Oops, I did not calculate, I just started with a number that surely
would be enough and then added "the sleep" in the same way.
But it also is interesting to find out that it did not cause any real
timeout. The only effect I realized was slowness.
Until then.
BR,
Örjan
PS. I´m swedish and live in the south of Sweden but was raised in
Hamburg.
>Hi Örjan,
>to let a problem rest for a while, is a good idea.
[quoted text clipped - 15 lines]
>Word XP, Win 98
>http://word.mvps.org/
Helmut Weber - 14 Nov 2004 20:02 GMT
Hi Örjan,
it seems, "timeout" wasn't clear enough,
or just the wrong word.
What I meant was "pause".
Bye.
---
Helmut Weber
?rjan Skogl?sa - 21 Nov 2004 12:02 GMT
Just FYI
I discovered that I hid the userform between runs.
Thus the routine "activate" was not executed. Or to be more precise,
it was not executed when the VBE was closed. Now I use unload instead
of hide and the problem has disappeared.
Just out of curiosity I made a little test and could confirm that with
my constellation (Word97 on Win2K) the built-in routine
UserForm_Activate only is run (after the userform has been hidden) if
the editor is open.
Best regards,
Örjan