Compile error: Assignment to constant not permitted

R

rick-global

I have a Word VB Script and template .doc file that has been working for many
years. Suddenly it seems to have stopped working using Word 2007. The code
still works perfectly on Word 2000. I did have a problem on Word 2003 back
in April 2005 but this was resolved by Peter Jamieson on this forum, which I
then tested with Word 2007 in 2006 & I recall it was fine.

Now I get:

"file conversion [filename], select the encoding that makes your document
readable"

followed by "Compile error: Assignment to constant not permitted"

See: http://www.sonytino.com/word2007/cerror.jpg

Any clues on how to fix this would be appreiciated.

As I said, Word 2000 works fine - no errors & it just creates the mailmerge
document with no problems.

Thanks
 
P

Peter Jamieson

wdSuffix is the name of a predefined enum constant in the Word object
(it's a member of the wdMappedDatafields enumeration), and setting it in
Word 2007 does cause the error you describe. I would actually expect the
same error in Word 2003 but not in Word 2000 because the relevant
enumeration wasn't defined in that version.

I guess you could choose a different variable name, or possibly use

Dim wdSuffix

within your function/sub to ensure that the name references a local
variant rather than the predefined constant.

Peter Jamieson

http://tips.pjmsn.me.uk
 
R

rick-global

Thanks for your help again Peter, that worked & no more compile error.

- Rick
 

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