Change Table Background Macro

J

Jeff Ditty

Hello-

I am trying to write a macro that will execute when a user selects a
checkbox. When the box is selected, I want the macro to select the table
that contains the checkbox and change the background color of the table. I
can get the checkbox to execute, but when I try to select the table it gives
me a runtime error "4065....command is not available". It appears that is
cannot find the table I am referring to....

I am selecting the table and changing the background using the following:

ActiveDocument.Tables(4).Shading .BackgroundPatternColor = wdColorGray50

Anyone have any ideas why it is not finding the table?

Thanks,

Jeff
 
J

Jezebel

If Word couldn't find the table, you'd get error 5941 'The requested member
of the collection does not exist'.

You're getting the 4065 error because the document is protected for forms,
which, amongst other things, prevents you making such changes. You need to
unprotect the form, make the changes, then re-protect (NoReset = true)
 

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