From: Squall Mania on
Hello,

I'm new into using Word-Matlab activex controls. I have a very simple equation and I want its result to be written into a Word Document using activex control. Here's my code:

x1=1;
x2=2;
result=x1+x2;
word = actxserver('Word.Application');
word.Visible = 1;
newdoc = word.Documents.Add;
Con=get(newdoc,'Content');
set(Con,'Text',result)

When I run the above code, MATLAB gives me an error: "??? Parameter must be a string."

Any solution to that?

Thanks
From: Andy on
"Squall Mania" <r_skeik(a)hotmail.com> wrote in message <hi7sa4$1p0$1(a)fred.mathworks.com>...
> Hello,
>
> I'm new into using Word-Matlab activex controls. I have a very simple equation and I want its result to be written into a Word Document using activex control. Here's my code:
>
> x1=1;
> x2=2;
> result=x1+x2;
> word = actxserver('Word.Application');
> word.Visible = 1;
> newdoc = word.Documents.Add;
> Con=get(newdoc,'Content');
> set(Con,'Text',result)
>
> When I run the above code, MATLAB gives me an error: "??? Parameter must be a string."
>
> Any solution to that?
>
> Thanks

% Try:

set(Con,'Text',num2str(result)); % note the conversion to a string