word 2000 作server,打开word文档时没有menubar, toolbar,formatbar,(200分)

  • 主题发起人 主题发起人 tanghz
  • 开始时间 开始时间
T

tanghz

Unregistered / Unconfirmed
GUEST, unregistred user!
我用 TWordApplication (2000)作server,建立实例。
下面这段代码打开word程序和文档。

。。。

WordApplication1.AutoQuit:=true;
ConfirmConversions := False;
ReadOnly := False;
AddToRecentFiles := False;
PasswordDocument := '';
PasswordTemplate := '';
Revert := True;
WritePasswordDocument := '';
WritePasswordTemplate := '';
Format := wdOpenFormatDocument;
Encoding:=EmptyParam;
Visible:=true;
Openandrepair:=true;
DocDirection:=EmptyParam;
NoEcodingDialg:=true;
WordApplication1.Documents.Open (fName, ConfirmConversions,
ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate,
Revert, WritePasswordDocument, WritePasswordTemplate,
Format,Encoding,Visible);


。。。

打开后的word程序没有所有的bar,和一般的打开状态不一样。我试过下面的代码
WordApplication1.CommandBars.Item[0].set_visible(true);
报错:无效索引



请各位高手帮忙。
 
我给你一段代码吧。。这个我一直在用,你可以参考写法。
var
FCommandBarName,FCommandBar:OleVariant;
begin
....
FCommandBarName:='Reviewing';
FCommandBar:=WordApplication.CommandBars.Add(FCommandBar,EmptyParam,EmptyParam,EmptyParam);
 
多谢答复,试了你的代码,还是什么都没有。

那位能有新招?
 
看看你的例子,我的例子我都正式给客户使用N-1年了。。
 
这是我的代码.麻烦给看看.



procedure TForm1.BtnOpenClick(Sender: TObject);
var
FPara: Paragraph;
FRange: Range;
ItemIndex ,fname,ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument, PasswordTemplate, Revert,
WritePasswordDocument, WritePasswordTemplate,FCommandBarName,FCommandBar,
Format,Encoding,Visible,Openandrepair,DocDirection,NoEcodingDialg: OleVariant;
Handle:Dword;
size:longint;

begin

if not OpenDialog1.Execute then exit;
fname:=OpenDialog1.FileName;
//Inialise the Word windows position
WordApplication1.WindowState:=wdWindowStateNormal;
WordApplication1.Move(0,0);
size:= screen.Width*7 div 10 ;
form1.Left:= (screen.Width*7 div 10)+1;
form1.Top:=0;
form1.Width:=screen.Width*3 div 10 -1;
form1.Height:=screen.Height;
form1.Resize;
WordApplication1.AutoQuit:=true;
ConfirmConversions := False;
ReadOnly := False;
AddToRecentFiles := False;
PasswordDocument := '';
PasswordTemplate := '';
Revert := True;
WritePasswordDocument := '';
WritePasswordTemplate := '';
Format := wdOpenFormatDocument;
Encoding:=EmptyParam;
Visible:=true;
Openandrepair:=true;
DocDirection:=EmptyParam;
NoEcodingDialg:=true;
WordApplication1.Documents.Open (fName, ConfirmConversions,
ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate,
Revert, WritePasswordDocument, WritePasswordTemplate,
Format,Encoding,Visible);
ItemIndex := 1;

WD1.ConnectTo(WordApplication1.Documents.Item(ItemIndex));

FPara := WD1.Paragraphs.Item(1);
FRange := FPara.Range.Words.Item(1);
FCommandBarName:='Standard';
FCommandBar:=WordApplication1.CommandBars.Add(FCommandBar,EmptyParam,EmptyParam,EmptyParam);


WordApplication1.Top:=3;
WordApplication1.visible:= true;

end;
 
真的呀,不过我给你搞定了。
procedure TForm1.Button1Click(Sender: TObject);
var
FOleFile:OleVariant;
SaveChanges,OriginalFormat,RouteDocument:OleVariant;
OleBackground,OleAppend:OleVariant;
OleRange,OleItems,OleCopies:OleVariant;
i:integer;
var
FCommandBarName:OleVariant;
FCommandBar:CommandBar;
begin
IF OpenDialog1.Execute THEN
FOleFile:=OpenDialog1.FileName;
WordXP.Disconnect;
try
WordXP.Connect;
except
//ErrMessage('RPC远程接口出错!强烈建议去除杀毒软件的嵌入模式。');
WordXP.Disconnect;
Abort;
end;
try
WordXP.Documents.OpenOld(FOleFile,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
FCommandBarName:='常用';
WordXP.CommandBars.Item[1].Set_Visible(True);

WordXP.Visible:=True;
WordXP.ShowMe;


except
on E:Exception do
begin
//ErrMessage('出错了,可能需要关闭所有的非法程序...'+#13+'错误号码:'+E.Message);
WordXP.Disconnect;
Exit;
end;//on:E
end;//try end
end;
 
还是不行,没有任何bar 显示
 
没人能解决吗?
 
后退
顶部