Solved

Page color not showing color

Posted on 2012-12-29
8
523 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
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
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

691 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