在word文件中定义了书签:sq1,为什么在程序执行到 Range.InvokeMethod ('InsertFile',['c:\a.rtf','sq1',False, False, False]);
时总是提示说“标签不存在!”,什么原因呀?
代码如下:
TOleContainer(DataEdit1.InplaceControl).DoVerb(0);
odoc:= TOleContainer(DataEdit1.InplaceControl).OleObject;
doc := System.DispatchHelper.Create(odoc);
owordApp:= doc.PropertyGet('Application', []);
wordApp := System.DispatchHelper.Create(owordApp);
wordApp.PropertyPut('DisplayAlerts', [False]);
osel:= wordApp.PropertyGet('Selection', []);
sel := System.DispatchHelper.Create(wordApp.PropertyGet('Selection', []));
oRange := sel.PropertyGet('Range', []);
Range := System.DispatchHelper.Create(sel.PropertyGet('Range', []));
try
begin
Range.InvokeMethod ('InsertFile',['c:\a.rtf','sq1',False, False, False]);
end;
finally
begin
(ofind as System.IDisposable).dispose;
(osel as System.IDisposable).dispose;
(owordapp as System.IDisposable).dispose;
(odoc as System.IDisposable).dispose;
end;
end; |