目前我正在尝试使用ActiveX和Matlab编写一些文本到Word。 这个文件: http : //www.mathworks.com/matlabcentral/fileexchange/9112-writetowordfrommatlab对我帮助很大。 但我无法弄清楚如何将超链接插入Word。
例如,我想添加与“www.test.de”相关的单词“test”。
我试过这个:
ActXWord = actxserver('Word.Application'); ActXWord.Visible = true; trace(ActXWord.Visible); word_handle = invoke(ActXWord.Documents,'Add'); ActXWord.ActiveDocument.Hyperlinks.Add('test','www.test.de');以及其他一些组合
ActXWord.ActiveDocument.Hyperlinks.Add方法。 但是Matlab不知道.Add方法。 我找到了一些像这样工作的Excel示例,但对于Word它不起作用。 有人知道问题可能是什么?
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.Addmethod. 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?
最满意答案
您的问题与MATLAB无关。 您没有正确调用ActiveX组件的Add方法。
这应该工作:
link = 'www.test.de'; ActXWord.ActiveDocument.Content.InsertAfter(link); ActXWord.ActiveDocument.Hyperlinks.Add(word_handle.Range(0, length(link)), link);无论如何,这与MATLAB无关; 有关更多信息,请参阅MS Word VBA参考 。
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.
更多推荐
发布评论