Upgraded to Office 2010, now Word automation not working from Matlab - The 'Color' property name is ambiguous in the 'Microsoft​_Word_14.0​_Object_Li​brary._Fon​t' class.

After performing a lot of calculations I am generating a word document via automation.
I create the document via:
MATLAB code
wordApp = actxserver('word.Application');
wordDoc = invoke(get(wordApp, 'Documents'), 'Add');
At one point I try and set the text color via:
MATLAB code
selection = wordApp.Selection;
selection.Font.Color = 255;
This worked fine (perfectly!) until I upgraded to Word 2010, now I get the error:
The 'Color' property name is ambiguous in the 'Microsoft_Word_14.0_Object_Library._Font' class.
I have tried a lot of googling and everything I can think of to fix this but no luck.
Does anyone have any ideas please?
Tom.

 채택된 답변

Typical, you spend a day googling then as soon as you post a question you find the answer. Seems it's now this:
MATLAB code
selection.Font.TextColor.RGB = textColor

댓글 수: 4

This is so helpful - I've been struggling to get some code to work all day. I have a really stupid question that I hope you can answer. Matlab will only allow me to use a scalar in the definition of textColor. How, then, do I define any colour that is not red?
Thanks! This worked perfectly for me. Replaced "actx_word_p.Selection.Font.Color ='wdColorAutomatic'" with "selection.Font.TextColor.RGB ='wdColorAutomatic'". Also replaced "SaveAs" with "SaveAs2".
Hi,
I'm having similar issue, I tried the above solution but i'm getting an error
Capture.JPG
a = ActXWord.Selection
I'm using matlab 2018b and MS office 365 ProPlus
Any ideas on this error ?
Jeeva

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

추가 답변 (1개)

tombola
tombola 2012년 3월 21일
Oh and SaveAs no longer works, you need to use SaveAs2

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

제품

태그

아직 태그를 입력하지 않았습니다.

질문:

2012년 3월 20일

댓글:

2019년 5월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by