我簡單說一下吧, 用TOleContainer顯示Word檔案, 可以這樣來實現, 只供參考.
procedure OpenWordFile(Target: TOleContainer; WordFile: String);
begin
Screen.Cursor:=crHourGlass;
wOldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
try
Target.DestroyObject;
if FileExists(WordFile) then begin
Target.CreateObjectFromFile(WordFile, False);
Target.DoVerb(ovPrimary);
setWordBars(Target, FALSE);
end;
else
Global.MsgDlg('FileNotFound', [mbOK]);
except
SetErrorMode(wOldErrorMode);
Screen.Cursor := crDefault;
end;
Screen.Cursor:=crDefault;
end;
procedure setWordBars(Target: TOleContainer; Show: Boolean);
begin
try
Target.OleObject.ActiveWindow.DisplayRulers := Show;
Target.OleObject.CommandBars['Menu Bar'].Enabled := Show;
Target.OleObject.CommandBars['Standard'].Enabled := Show;
Target.OleObject.CommandBars['Formatting'].Enabled := Show;
Target.OleObject.CommandBars['Drawing'].Enabled := Show;
except
ShowMessage(Exception(ExceptObject()).Message);
end;
end;