06-21-2016 02:00 PM
Hi Guys,
I need some help. I have I have to compare some dates in a table, if I find a date that is older than today date,I have to shade or color the background of that cell in green or red and put the table in a word report.
Attached is what I am trying. For now I am just dealing in coloring just for January. If it works, I will apply it to other months.
Need some help please.
Solved! Go to Solution.
06-21-2016 02:21 PM - edited 06-21-2016 02:28 PM
I wasn't able to get the "Jan" case or "January" cases to activate the way your code is now, so I added a Trim Whitespace node before the case structure and it worked.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-21-2016 02:52 PM
Yes my real probleme is how to color only the cell that is needed. I put everything to gether for you guys to have all in one. But really coloring the cell that where I am getting stacked.
06-21-2016 03:03 PM - edited 06-21-2016 03:23 PM
Is there a reason you aren't doing this in excel? That's the better/easier option here when you dive in to cell manipulation.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-21-2016 03:17 PM
A few more comments.
In your months array you are using abbreviations like "Jan.", you should be aware that in regular expressions the dot is a special character that matches any character (probably not what you want). Even it it matches "Jan." you don't have a "Jan." case in your case structure. The simplest fix is to remove the dot in your constant month array (note that in this case the Jan regex will return a match for the January string).If you specifically want to match "Jan." use Jan\. i your month array, the backslash is an escape character (\. will match the dot character). I don't know where your output array is coming from but you will have to find a way to insure the calibration dates are entered in the expected format.
Ben64
06-21-2016 03:22 PM
So definitely pay attention to my comments above and ben's comment about your string formatting. If you ignore these suggestions and only fix the one thing you're asking about, you will be back here with more questions or spend a whole lot of extra time debugging your code.
As for the specific cell background color, you can access the Word.Tables object instead of the Document object you were using. From this, you can go to a specific cell and set the color. Like so:
I added this to your code and it worked. The numeric input coming from the left is wired to the For loop index, so that is goes to the correct row for whatever cell you are parsing now. A key thing to notice here is that the report indices are base 1 instead of base 0.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-21-2016 03:26 PM
@James.M wrote:So definitely pay attention to my comments above and ben's comment about your string formatting. If you ignore these suggestions and only fix the one thing you're asking about, you will be back here with more questions or spend a whole lot of extra time debugging your code.
As for the specific cell background color, you can access the Word.Tables object instead of the Document object you were using. From this, you can go to a specific cell and set the color. Like so:
I added this to your code and it worked. The numeric input coming from the left is wired to the For loop index, so that is goes to the correct row for whatever cell you are parsing now. A key thing to notice here is that the report indices are base 1 instead of base 0.
Even simpler than that, use Word Table Borders and Shadind.vi from the Word Tables palette!
Ben64
06-21-2016 03:32 PM
@ben64 wrote:Even simpler than that, use Word Table Borders and Shadind.vi from the Word Tables palette!
Well I'll be, the whole reason one pays for the report generation toolkit.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-22-2016 02:30 PM
Thanks, this helps.