02-23-2016 06:16 AM
Hello all,
I am new to DIAdem and I am trying to format the already existing report templete which contains the table in which rows are defined usind the textlist. I am trying to vary the font color as per the values in every column.
I tried to write the script and it functioned well when a column of a table is a channel but for the textlist whose columns are made of different channel values, I am not able to find anything. Is it even possible to achive while using textlist, if yes then please guide me through.
Regards
Solved! Go to Solution.
02-24-2016 06:28 AM - edited 02-24-2016 06:29 AM
Hi Sarry,
You need to create and register a user command that will be executed when drawing any cell in the table.
User commands can be registered like this:
'register user command for the first column in the first table of the first sheet Report.Sheets(1).Objects(1).Columns(1).Settings.OnDrawingCell = "TableDrawingCell"
In my example there must be a procedure called "TableDrawingCell" in another vbs file that is registered under Settings»Options»Extensions»User Commands.
Each time the "OnDrawingCell" Event is called, you can access cell indices with Context.Col and Context.Row to decide if you want to change color for the current cell.
If you want to change font colors (e.g. to red) you can use the following code:
Cell.Font.Color.SetRGBColor(RGB(255, 0, 0))
Attached you can find a simple example.
Regards Christian
02-24-2016 07:06 AM
Hi Sarry,
It looks like you've uncovered a bug in DIAdem 2015. R&D looked into this and discovered that only the first column of a table with "Text List" columns can be conditionally formatted with a UserCommand.
Thanks for pointing that out,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
02-24-2016 08:20 AM
Hi,
Thats good. It would be great if you can solve such an issue. Please do update with the status regarding the same.
Regards
02-24-2016 08:48 AM
Hi Brad,
Thanks for the information.
In my example it seemed to work or did I misunderstand the issue?
Regards
Christian
02-24-2016 04:36 PM
Hi Christian,
Actually, your example does work for me in both DIAdem 2014 and DIAdem 2015. Now I'm not sure what R&D is referring to.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
02-25-2016 01:27 AM
Hi Christian,
Thanks a lot for the solution. By looking at your example it looks like it is possible with the text list as well.
Regards
02-25-2016 03:06 AM
Hi CHristian,
In the example you have provided it is using the color info provided by the user in TagTemporary but I want to decide the color based on the value the cell is having. How can I do that. It would be great if you can guide.
Regards
02-25-2016 03:38 AM - edited 02-25-2016 03:46 AM
Hi Sarry,
you can use Cell.Value to access each cells value.
In my example just make to following changes:
if Cell.Value = "Insert conditional value here" then ... Cell.Font.Color.SetRGBColor(RGB(255, 0, 0)) end if
Here you can find documentation about that (see properties at the end):
Best regards
Christian
02-25-2016 05:41 AM
Hi,
Thanks a lot and it looks like it is working except one thing. It seems like it is looking at the very first position of the value as you can see in piture. I asked to make it red if value is greater then 2 else make it green. So its making all values starting with 1 green even though the are greater than 2. Can you please guide further?