Word的ActiveX控件.选择文字和图片 [英] ActiveX control of Word. Select text and images

查看:117
本文介绍了Word的ActiveX控件.选择文字和图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我到目前为止所做的:

This is what I have done so far:

word = actxserver('Word.Application');

document = word.documents.Open('C:\Documents and Settings\kz7213\Desktop\Test.docx');

selection = word.Selection;

selection.TypeText('Big Finale'); 
selection.Style='Heading 1'; 
selection.TypeParagraph;

FIG1 = figure('Visible','off'); plot([1 2 3 4 5],[4 1 3 5 7]);

print -dmeta

selection.Paste; 

selection.Style='Heading 1';

selection.InsertCaption('Figure','Test figure 1'); %Not working
selection.Style='CaptionStyle';

selection.TypeParagraph;

如何选择先前输入的文本(例如大结局")进行编辑,或者选择我随选择粘贴的图形.粘贴命令以便为图像添加标题?

How can I select previous entered text such as "Big Finale" to edit it, or select the figure I pasted with the selection. Paste command in order to make a caption for the image?

推荐答案

VBA中针对MS Word的可能解决方案:

Possible solution in VBA for MS Word:

'to find a text
    Selection.Find.Execute FindText:="Big Finale", Wrap:=wdWrapAlways

'to select inline shape
    ActiveDocument.InlineShapes(1).Select

查找内联形状的替代方法是使用.Find.Execute method并进行以下设置:

Alternative solution to find a inlineshape(s) is to use .Find.Execute method with the following settings:

Selection.Find.Execute FindText:="/", Wrap:=wdWrapAlways, MatchWildcards:=True

这篇关于Word的ActiveX控件.选择文字和图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆