使用Matlab activeX在Word中创建超链接(Create a Hyperlink in Word using Matlab activeX)

编程入门 行业动态 更新时间:2024-10-10 02:18:28
使用Matlab activeX在Word中创建超链接(Create a Hyperlink in Word using Matlab activeX)

目前我正在尝试使用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.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?

最满意答案

您的问题与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.

更多推荐

本文发布于:2023-08-06 18:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1453606.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:超链接   activeX   Matlab   Word   Hyperlink

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!