Word VBA question

M

michaelgaihede

Hi,

I'm having a lot of trouble trying to color a particular area in my document.
For example, using:

ActiveDocument.Bookmarks(Selection.BookmarkID).Range.Shading.
BackgroundPatternColor = wdColorRed

I receive a "Run-time error 4605 - This command is not available". As it
turns out, it's the Shading object within the Range object that, appparently,
does not have/support assignment of the
BackgroundPatternColor. Why not ?

For your information, the BookmarkID points to a bookmark on a formfield
within a table cell.

Any ideas will be highly appreciated. Thanks.
 
J

Jonathan West

michaelgaihede said:
Hi,

I'm having a lot of trouble trying to color a particular area in my
document.
For example, using:

ActiveDocument.Bookmarks(Selection.BookmarkID).Range.Shading.
BackgroundPatternColor = wdColorRed

I receive a "Run-time error 4605 - This command is not available". As it
turns out, it's the Shading object within the Range object that,
appparently,
does not have/support assignment of the
BackgroundPatternColor. Why not ?

For your information, the BookmarkID points to a bookmark on a formfield
within a table cell.

I think that last throwaway line holds the key to the problem. When a
document is protected for forms, a large number of the normal VBA commands
for manipulating a document become unavailable.

I suspect you will have to unprotect the document, apply the shading, then
reprotect the document.
 

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