Coloring string, fprintf seems limited and cprintf is even a thing?
4 views (last 30 days)
Show older comments
Md Jonayet on 20 Mar 2023
Commented: Walter Roberson on 30 Mar 2023
I am trying to modify a pass/fail function which prints the results in MS word template. Right now it just print 'Pass' in black and white formet but I want to color it as green.
How can I color the text ?
function reportgen_replace(hfind, fromstr, tostr)
%The argument tostr return a string name Pass
% Execute the replacement
if strcmp(tostr, 'Pass') %I made this function just to give a try but it does not seem to work
ColorPF = fprintf(2,'Pass'); %Although I need green color, I know that this function return text in red so I just wanted to give a shot
invoke(hfind, 'Execute', fromstr, 0, 0, 0, 0, 0, 1, 1, 0, ColorPF, 2);
%instead of printing any string, it return values (4
Walter Roberson on 20 Mar 2023
cprintf is a File Exchange contribution. You can install it using the Add-On Explorer.
The return value from fprintf() is the number of bytes converted, not the text.
Walter Roberson on 30 Mar 2023
Find more on ActiveX in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!