Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Page Background Problem in Word 2007

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
szcz.andrew@gmail.com - 17 Dec 2007 14:10 GMT
Hello everyone,

 I'm trying to change the page color using VBA in Word 2007 and I am
having problems/finding inconsistancies - perhaps someone can help.

 I understand that the 'page color' is *supposed* to be visible only
in WebView, but Word does allow you to change the color of the page as
seen in Page Layout, and I would like to do the same thing using VBA.

If you use the ribbon to change the page color, it works fine.  If
you record this action, it generates the following code:

   ActiveDocument.Background.Fill.ForeColor.ObjectThemeColor = _
       wdThemeColorAccent1
   ActiveDocument.Background.Fill.ForeColor.TintAndShade = [your
color]
   ActiveDocument.Background.Fill.Visible = msoTrue
   ActiveDocument.Background.Fill.Solid

 This generated macro does not work on a new document (it is
incomplete).  In fact, this code will only work if the page color has
been changed using the ribbon at least once.  On a brand new document,
it does not change the page color as seen in page layout view.

 This means the ribbon page color action performs some additional
work to ensure that page background colors are visible in page layout
view.  Anyone have a clue as to what this code may be?

Sincerely,
Andrew
Tony Jollans - 17 Dec 2007 19:43 GMT
>  I understand that the 'page color' is *supposed* to be visible only
> in WebView, but Word does allow you to change the color of the page as
> seen in Page Layout, and I would like to do the same thing using VBA.

In 2007, Page Backgrounds are visible everywhere, not just in Web layout.

>  This means the ribbon page color action performs some additional
> work to ensure that page background colors are visible in page layout
> view.

You are absolutely correct. The page background colour *is* set in your
code, and is saved with the document, but it also has to be set to be
visible. Add this to your code:

   ActiveDocument.ActiveWindow.View.DisplayBackgrounds = True

Signature

Enjoy,
Tony

> Hello everyone,
>
[quoted text clipped - 26 lines]
> Sincerely,
> Andrew
szcz.andrew@gmail.com - 18 Dec 2007 04:31 GMT
Tony, you're wonderful!  That worked perfectly - much appreciated!

Cheers,
Andrew
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.