Solved

Page color not showing color

Posted on 2012-12-29
8
519 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 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
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 

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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

726 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