Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Greetings.
I have a macro that sets variables that is setting a start and end age:
ActiveDocument.Variables("vAgeEnd").SetContent "63", true
ActiveDocument.Variables("vAgeStart").SetContent "23", true
There are all sorts of age ranges that it sets, based on a number of things in the system. Occasionally, it will set one age, and not the other. I found that if I changed the order of the settings (Usually I set vAgeStart first, then the vAgeEnd) it "fixes" the problem, but then later on, if I happen to be coming from a particular selection, it won't work. In some cases, in the one macro, I set these two variables more than once.
Has anyone ever seen anything like this? Is it a known problem? Its killing me, because I'm constantly rechecking my code, thinking I've programmed something wrong.
Thanks.
DUH.
I forgot I had constraints on these. If the new vAgeStart date was greater than the current vAgeEnd, it wouldn't update the variable (but I got no warning message like if I tried to do it manually). So. I check for the old values before adding the new values and it all works file.
Sally,
Try to insert WaitForIdle or Sleep before each variable setting.
I tried with WaitForIdle, but didn't seem to make a difference (other than generally slowing down the screen). But I may have not tried it before each setting. I'll give that a try and see what happens.
Did the following:
ActiveDocument.GetApplication.WaitForIdle 3000
ActiveDocument.Variables("vAgeEnd").SetContent "1", true
ActiveDocument.GetApplication.WaitForIdle 3000
ActiveDocument.Variables("vAgeStart").SetContent "1", true
ActiveDocument.GetApplication.WaitForIdle 3000
And vAgeEnd remained the 999 it was before executing these statements.
DUH.
I forgot I had constraints on these. If the new vAgeStart date was greater than the current vAgeEnd, it wouldn't update the variable (but I got no warning message like if I tried to do it manually). So. I check for the old values before adding the new values and it all works file.