Word 2007: Options.ReplaceSelection -> Run-time error 4120 Bad Parameter

H

Hans

Hi,

In April, jalanford wrote a carefully composed message in
microsoft.public.word.vba.general on the subject of run-time errors when
trying to set a number of parameters like Options.[SomeParameter] via VBA.

The problem occured only on some machines with Word 2007 and Windows XP. We
can't reproduce it on our machines, and we have no direct access to machines
affected by the problem.

But we have the same problem with a small number of our customers and are
looking for the best way to make our add-in work on their systems - other
then writing a patch for our software, which we will do anyway. If the
registry is involved, even a patch will probably require some "manual"
action by the customer in certain cases. So far, we succest to run our Word
add-in on a newly created user account, which worked in all known cases, but
is far from ideal, of course.

Unfortunately, the discussion then in the newsgroup stopped before someone
provided a solution. The only suggestion was to repair the registry, but
there was no follow-up.

Could jalanford or someone else please give some advice how you worked
around the problem? If so, I would try to compile an answer to the problem
for the newsgroup.

Thanks in advance

Hans
 
J

JimmyHoffa

After encountering the same problem on a customers machine and much
head scratching, my solution was to make sure that in word options
that the Username and Initials are not blank, or a space... it
appears if they are, you cannot set certain word options without
getting the runtime error 4120 bad parameter.. Another fine MS bug.
 
H

Hans

Thanks a lot!

From your hint, I could finally and regularly reproduce the run-time error
4120 (or 24 with a password protected project) on my machine when using the
VBA command Options.ReplaceSelection = True or other variants of
Options.[something]. Simply by clicking the Office button, then
Word-Options, then changing the contents of the Username field to a blank
space.

It was not possible for me to get the Username field to be entirely empty,
not even by manually editing the registry keys
....\Software\Microsoft\Office\Common\UserInfo, where the information is
stored. When I tried to delete it's whole content, either in the registry or
in the Word options dialog, the registry value or options Username field was
always automatically reset to contain the name of the Windows XP user
account.

The Initials field alone did not do the trick, though I couldn't get that
entirely empty, too.

I'm not sure how the Username field can happen to contain a blank space (or
nothing at all) after installing Office 2007 in the first place. But we had
at least 6 customers in different parts of the country with this problem, so
the chances seem to be not totally negligible. In one case, half of the
machines in a school classroom were affected.

I'll do some additional tests and ask our customers to verify the solution,
then come back with a summary.

Hans

JimmyHoffa said:
After encountering the same problem on a customers machine and much
head scratching, my solution was to make sure that in word options
that the Username and Initials are not blank, or a space... it
appears if they are, you cannot set certain word options without
getting the runtime error 4120 bad parameter.. Another fine MS bug.


Hi,

In April, jalanford wrote a carefully composed message in
microsoft.public.word.vba.general on the subject of run-time errors when
trying to set a number of parameters like Options.[SomeParameter] via
VBA.

The problem occured only on some machines with Word 2007 and Windows XP.
We
can't reproduce it on our machines, and we have no direct access to
machines
affected by the problem.

But we have the same problem with a small number of our customers and are
looking for the best way to make our add-in work on their systems - other
then writing a patch for our software, which we will do anyway. If the
registry is involved, even a patch will probably require some "manual"
action by the customer in certain cases. So far, we succest to run our
Word
add-in on a newly created user account, which worked in all known cases,
but
is far from ideal, of course.

Unfortunately, the discussion then in the newsgroup stopped before
someone
provided a solution. The only suggestion was to repair the registry, but
there was no follow-up.

Could jalanford or someone else please give some advice how you worked
around the problem? If so, I would try to compile an answer to the
problem
for the newsgroup.

Thanks in advance

Hans
 

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