Reputation: 91
Currently I am trying to write some Text to Word using ActiveX and Matlab. This file: http://www.mathworks.com/matlabcentral/fileexchange/9112-writetowordfrommatlab helped me a lot. But I can't figure out how to insert an Hyperlink to Word.
e.g. I want to add the the word "test" connected with "www.test.de".
I've tried this:
ActXWord = actxserver('Word.Application');
ActXWord.Visible = true;
trace(ActXWord.Visible);
word_handle = invoke(ActXWord.Documents,'Add');
ActXWord.ActiveDocument.Hyperlinks.Add('test','www.test.de');
and also some other combinations with the
ActXWord.ActiveDocument.Hyperlinks.Add
method. But Matlab doesn't know the .Add method. I found some Excel examples which are working like this, but for Word it doesn't work. Somebody has an idea whats the problem could be?
Upvotes: 0
Views: 964
Reputation: 486
Your issue is not really related to MATLAB. You are not calling the Add
method of the ActiveX component correctly.
This should work:
link = 'www.test.de';
ActXWord.ActiveDocument.Content.InsertAfter(link);
ActXWord.ActiveDocument.Hyperlinks.Add(word_handle.Range(0, length(link)), link);
Anyway, this is not related to MATLAB; for more information you should refer to MS Word VBA reference.
Upvotes: 0