我要在程序中调用word,首先要派断本地机是否装了OFFICE,还有获得它的全路径,请教各位怎么做

解决方案 »

  1.   

    [转载]2. late binding
        后期绑订,使用IDispatch接口,代码编译时并不了解你所需要操作的对象是什
    么,程序运行过程中(Runtime)才实现和OLE服务器的真正连接,所有变量使用Variant
    类型,代码性能应该较差(仅仅猜测)。但是这种方式代码较为简单易懂,易于自己编写
    复杂的控制。以下是一个同样打开Access程序的代码。 var
       Access: Variant;
     begin
       try
         Access := GetActiveOleObject('Access.Application');
       except
         Access := CreateOleObject('Access.Application');
       end;
       Access.Visible := True;
             ...
     end;
      

  2.   

    判断OFFICE需要根据调用不同的程序分别判断。
    ExtractFilePath('winword.exe');//获得Word的可执行文件的全路径
      

  3.   

    注册表中HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\office\10.0(或9.0、8.0)\Word\InstallRoot
    读Path的值
      

  4.   

    我装了office了,为何调用ExtractFilePath('winword.exe')返回的却是空字符串。
      

  5.   

    我觉得没有考虑这个问题啊,你可以直接创建一个关于WORD的Application啊
      

  6.   

    feibob(灵猫)老兄,你能否说的具体点(最好有个例子)
      

  7.   

    1、利用wordapplication控件
    启动word时用如下代码: 
    begin
    try 
    wordapplication.connect; 
    except 
    messagedlg('word may not be installed', mterror, [mbok], 0); 
    abort; 
    end; 
    wordapplication.visible := true; 
    wordapplication.caption := 'delphi automation'; 
    end; 
    2、CreateComObject('Word.appliction')
      

  8.   

    try
          ExcelApp := CreateOleObject('Word.application');
        except on raise '未装word';
          
      

  9.   

    try
        MSExcel := CreateOleObject('Word.Basic');
      except
        ShowMessage('Could not start Microsoft Word.');
        Exit;
      end;
      try
      except
        try
        except
           ShowMessage('Microsoft Word version is not German, French or English.');
           Exit;
        end;
      end;
      

  10.   

    private
        v: variant;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
    try 
    wordapplication.connect; 
      v := CreateOleObject('Excel.Application');
      v.visible := True;
    except 
    messagedlg('word not installed', mterror, [mbok], 0); 
    abort; 
    end; end;
      

  11.   

    v := CreateOleObject('Excel.Application');
    改为 v := CreateOleObject('word.Application');
      

  12.   

    顺便问一下,TWordApplication的帮助在什么地方
      

  13.   

    再问一下,如果运行Word的同时要打开一个文档怎么做
      

  14.   

    简单!
    begin
       mystring:='.doc'; 
       FReg:=TRegistry.Create ; //创建TRegistry对象
       FReg.RootKey :=HKEY_CLASSES_ROOT;    
       if FReg.OpenKey(mystring,False) then 
       begin
         mystring:=FReg.ReadString(''); 
         FReg.CloseKey ;
         Mystring:=mystring+'\'+'shell'+'\'+'open'+'\'+'command'
         FReg.OpenKey(mystring,False);
         mystring:=FReg.ReadString(''); 
         showmessage(trim(mystring));//显示相应的应用程序完整信息
       end
    end;
      

  15.   

    到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe看看,一定有你想要的东西!!!
      

  16.   

    var wordfile:olevariant;
    begin
      try
       wordfile:=createoleobject('word.basic');
      except
      showmessage('could not find word');
      exit;
      if (lang='English (US)')or (lang='English (UK)') then
     begin
       msword.appshow;
      msword.fileopen('22.doc');
      mswrod.filesaveas(format:=6,name:='dfdfd.htm'); //转存为htm格式