Word2007 and Windows7 problem

M

Mo

Hi,
In Windows7 and Word2007 (vba version 6.5.1020) I have a problem with code
that runs fine on Windows XP and Word2007(vba version 6.5.1543) .
The following code sits in a template:

Sub Test()
Dim x As Boolean
x = False
Application.Run "Change", x
MsgBox x
End Sub

And the following code sits let's say in normal.dot:

Sub change(bprotect As Boolean)
bprotect = Not bprotect
End Sub

If I run the "Test"-macro the result in Windows XP is a msgbox that shows
"True" and in Windows7 the msgbox shows "False". In the latter case it
doesn't pass the variables changed value.

What could cause this?
Thanks
Peeter
 
T

Tony Jollans

Does it work if you single step through it.

I suspect this is a timing issue. AFAIK, Application.Run runs things
asynchronously and it is up to Word how it co-ordinates things - you should
not rely on things started this way having completed immediately.

I don't currently have a Windows 7 system available to test with - maybe
later tonight.
 
M

Mo

Hi Tony and thanks,

this could also be a timing problem. I couldn't make it work before, but now
before getting back to you on this, I can't reproduce the error...it works as
i expected it to. Maybe it has nothing to do with Windows 7, or maybe it has
:)

Thanks again
P
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top