简体   繁体   中英

Mac MS Word change background color with macro

Is there a macro for changing page background color (using RGB) in Word for mac? The macro for word on a PC does not work for word on mac. I tried the “record macro” tool but that did not help. It was just a blank macro. Thanks!

Here's the macro I use in pc word:

 ‘’’
ActiveDocument.ActiveWindow.View.DisplayBackgrounds = True
ActiveDocument.Background.Fill.Visible = msoTrue
ActiveDocument.Background.Fill.ForeColor.RGB = RGB(200, 222, 250)
ActiveDocument.Background.Fill.Solid

I am not on a Mac, but see if one of the Word color constants meets your needs.

So, I can't tell you why your macro is not working. I'm sorry.

Instead of ActiveDocument.Background.Fill.ForeColor.RGB = RGB(200, 222, 250) try something like ActiveDocument.Background.Fill.ForeColor= wdColorLightGreen . That corresponds to RGB = 204, 255, 204.

Here is a list of the Word Color Constants with the corresponding RGB settings.

Unfortunately, this won't work on the Mac version because it does not let you access the Document.Background object. If you look for it in View->Object , it is there but it is hidden.

AIUI if you set the background color on Windows, you can still see it on Mac, and print it on Mac if you check the relevant option in Word->Preferences . You just can't set it or change it.

I can't see any particularly good alternative either. I can't see a way to do this in AppleScript. You could create a page-sized rectangular shape in a header or footer (so that it appears on all pages in a Word section) and specify a fill, but that will behave differently (Ie it will probably print whatever is set in Preferences, and if your document has multiple sections, you will need to ensure that the shape is in all of them). Or if you saved the document in Word XML format, you could add/modify necessary XML elements there. You'd have to inspect a document created on the windows version to find out exactly what XML you needed. (I cannot see a way to insert this XML using VBA's InsertXML method either).

NB I do not have enough points here to post comments, so if you have any follow-up, look for changes in this Answer (assuming I can change it!)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM