Jump to content

Help setting background color in Word


grakker
 Share

Go to solution Solved by orbs,

Recommended Posts

I'm writing a little script that creates a form in word. I first create a table using something like:

Send("{ASC 43}")
Send("{TAB}")

And looping through it 10 times to create something like:

+     +     +     +     +     +     +     +     +

Then send enter and get my 10 row table.  Then I go back through it labeling cells 1-10. That part works fine. What I need to do (This is for tracking credits for students, doing in manually is just repetitive and obnoxious) is highlight a given number of cells. Like if the student has completed 6 credits, 1-6 get's formatted with a yellow background. Something like

_Word_Format_background(#FFFBCC)

I suppose I could do it in Excel, but the form has a bit of writing as well and I thought it would work better in Word. If anyone could help me, I'd be appreciative for sure.

Link to comment
Share on other sites

  • Solution

pull the emergency break, switch to Excel, use conditional formatting, and you're done.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Why create the form by a script? Manually create a template, do all the formatting there and only fill in the data by your script.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

pull the emergency break, switch to Excel, use conditional formatting, and you're done.

 

Yeah, that's pretty much the way I was thinking I would have to go. Wouldn't even have to go to conditional formating as my data comes like 40:13:27 (Requirement:Completed:Needed).

 

Why create the form by a script? Manually create a template, do all the formatting there and only fill in the data by your script.

 

Well, here was my thinking, backwards as it may be: I would like to give this to several colleagues who are asked to do this for students several times a day. I could just tell them to copy the data to a clipboard and run the script. They aren't the most technologically inclined and I worried that they would glass over if I mentioned using a template. At which point they would continue using a blank form and manually highlighting it. Which just bugs me for some reason.

Link to comment
Share on other sites

I see. Whether Excel or Word is the best solution depends on the amount of formatting you need for the text. Word is a bit more complex to automate using AutoIt.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Well, for what it's worth, I went with Excel and a template. Knocked it out during lunch and sent it around to the colleagues. They were all impressed. It's funny to me that my very rudimentary skills impress people. Need to work on programming literacy...  Thanks for the replies.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...