Einzelnen Beitrag anzeigen

nahpets
(Gast)

n/a Beiträge
 
#3

AW: Mehre Excel Instanzen Verwalten.

  Alt 10. Okt 2016, 17:09
Hier mal sowas in der Art (nur mit Word):
Delphi-Quellcode:
function tForm1.DokumentOeffnen(
  aWordDocument : TWord11Document;
  aDateiname : String;
  aVisible : Boolean = false) : Boolean;
var
  vDateiname : OleVariant;
  vVisible : OleVariant;
  vFalse : OleVariant;
begin
  try
    vDateiname := aDateiname;
    vVisible := aVisible;
    vFalse := False;
    WordApplication.Connect;
    WordApplication.Documents.Open(vDateiname, EmptyParam, vFalse, vFalse,
                                   EmptyParam, EmptyParam, EmptyParam, EmptyParam,
                                   EmptyParam, EmptyParam, EmptyParam, vVisible,
                                   EmptyParam, EmptyParam, EmptyParam, EmptyParam);
    aWordDocument.ConnectTo(WordApplication.ActiveDocument);
    Result := True;
  except
    on e : Exception do begin
      Result := False;
    end;
  end;
end;
Dieser Funktion wird eine Variabel vom Typ TWord11Document übergeben. Von denen gibt es im Programm mehrere. Das Ganze ist mit Delphi 7 geschrieben und nutzt Word_TLB.

Mit Excel müsste das analog auch gehen. Für jede Exceldatei 'ne eigene Variabel.
  Mit Zitat antworten Zitat