All pastes #977133 Raw Edit

dimensiOn

public text v1 · immutable
·published 2008-04-08 17:21 UTC
rendered paste body
      // Cria o link OLE com o OpenOffice
      if VarIsEmpty(OpenOffice) then
        OpenOffice := CreateOleObject('com.sun.star.ServiceManager');
      Connect := not (VarIsEmpty(OpenOffice) or VarIsNull(OpenOffice));

      // Inicia o Calc
      OpenDesktop := OpenOffice.CreateInstance('com.sun.star.frame.Desktop');
      cFile := 'file:///'+ExtractFilePath(ParamStr(0)) + 'Planilhas\Fluxo.sxc';
      cFile := StringReplace(cFile, '\', '/', [rfReplaceAll]);
      Calc := OpenDesktop.LoadComponentFromURL(cFile, '_blank', 0, VarArrayCreate([0, -1], varVariant));
      //procura o handle do arquivo cFile pelo título, se não achar
      //o programa procura por "título (somente leitura)"
//      ShowMessage(cFile);
//      ShowMessage(Copy(cFile,9,Length(cFile)-12));
      AppHandle := FindWindow(Nil,PAnsiChar(Copy(cFile,9,Length(cFile)-12)+' - BrOffice.org Calc'));
      if (AppHandle=0) then
        AppHandle := FindWindow(Nil,PAnsiChar(Copy(cFile,9,Length(cFile)-12)+' (somente leitura) - BrOffice.org Calc'));
      if (AppHandle=0) then
        AppHandle := FindWindow(Nil,'Fluxo - BrOffice.org Calc');
      //esconde a planilha
      ShowWindow(AppHandle, SW_HIDE);