Solved

Page color not showing color

Posted on 2012-12-29
8
517 Views
Last Modified: 2012-12-30
Using Word with VBA, I have a program that creates a document similar to another open document. To distinguish the two, I add some code that specifies a tan page color (excuse the bad formatting; my fault):
        ActiveDocument.Background.Fill.ForeColor.ObjectThemeColor = color:
        wdThemeColorBackground2 color:
        ActiveDocument.Background.Fill.ForeColor.TintAndShade = -0.1
color:
        ActiveDocument.Background.Fill.Visible = msoTrue
        ActiveDocument.Background.Fill.Solid.

It does not seem to change the background at all as shown on the screen, yet when printed or when viewed in Full Screen Reading, the tan color shows clearly.
What am I doing wrong?

j.r.a.
0
Comment
Question by:JohnRobinAllen
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 13

Expert Comment

by:themrrobert
ID: 38729909
0
 
LVL 22

Expert Comment

by:Flyster
ID: 38730152
I was getting the same results as you. I then went to the Page Layout tab and under Page Background selected Page Color – White Background. I ran your code again and it was working. If this works for you and you would like to know why….. Sorry, I can’t help there. I’m just filing this one under P.D.L. (Pure Dumb Luck)!!

Flyster
0
 
LVL 13

Expert Comment

by:themrrobert
ID: 38730242
Yea, I also noticed the code started working after i played with the background settings, however the color the code changed it to, was not the same color as the background color was in the reading pane before. (I use Word 2007)

It definitely seems like it's (Word is) a bit buggy when it comes to background color, but that's microsoft for you.  

good luck
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:JohnRobinAllen
ID: 38730265
The problem may be with my computer. The sample file below illustrates the problem on my computer. May I ask if it gives you the same problem: background appears white unless printed or viewed in full screen reading mode?
     I can easily change the background manually, but my goal is to have VBA do the changes. I recorded a macro to make such changes, and it works fine. The recorded code, however, produces a file like the one attached below.
     This morning I did some work with copying modules from one document to another, and that may have wreaked havoc on my machine. I'll know more if others do not have the problem I described when they load up the document below.

j.r.a.
Sample.docx
0
 
LVL 22

Expert Comment

by:Flyster
ID: 38730418
OK, when I opened this document, it was white. I went to Page Layout - Page Color - More Color. It was showing the currrent color as brown. When I selected OK, the document turned brown. This happened both on Word 2007 and 2010.
Sample2.docx
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 38730580
By default, page backgrounds are not displayed, so you need a line like this:
    ActiveWindow.View.DisplayBackgrounds = True
in the code.
0
 

Author Closing Comment

by:JohnRobinAllen
ID: 38730787
Flyster’s comment Posted on 2012-12-30 at 00:16:12 is accurate, and I had done that also. It doesn’t help. My question wasto be able to make the change using VBA.

     Graham Skan’s one-line solution works perfectly and solves the problem. Mr. Skan made a suggestion on another problem I had, and his suggestion was close to the correct solution. Unfortunately I had written my acceptance of the solution awarding 500 points to someone else before I saw Graham’s solution. 250 of those points should have gone to Graham. I am therefore boosting the number of points awarded for this solution to 500, which returns 205 of the points I should have awarded earlier.

     Even without that background, the one-line solution is so elegant, it deserves the maximum number of points anyway. Thanks, always, the contributions of G.S. to E.E.

     j.r.a. in Priddis (Alberta)
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38730882
Thanks j.r.a. It wasn't really a problem. As you said, Chris had already pointed to the answer, and you made it clear what the answer was by posting the final code.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question