필터 지우기
필터 지우기

Coloring string, fprintf seems limited and cprintf is even a thing?

조회 수: 15 (최근 30일)
Md Jonayet
Md Jonayet 2023년 3월 20일
댓글: Walter Roberson 2023년 3월 30일
Hello there,
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);
end
%instead of printing any string, it return values (4

답변 (1개)

Walter Roberson
Walter Roberson 2023년 3월 20일
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.
  댓글 수: 7
Md Jonayet
Md Jonayet 2023년 3월 20일
Hey Walter, it seemed like the exact thing that I need to learn now. Could you give me some good keyword, source or any source to learn about it fully in depth? I would greatly appreciate it.
is wordtext a function by user defined?
WordText(ActXWord,TextString,Style,[0,1],'wdRed');
Walter Roberson
Walter Roberson 2023년 3월 30일
WordText is defined in the SUB-FUNCTIONS portion of the 9112 File Exchange contribution.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by