1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34:
| procedure TForm1.Button1Click(Sender: TObject); var s:olevariant; begin s:='c:\test.doc'; with WordApplication1 do begin //neues Dokument WordDocument2.connectto(Documents.Add(emptyparam,emptyparam)); //einzufügendes Document öffnen WordDocument1.ConnectTo(Documents.open(s, Emptyparam,Emptyparam,Emptyparam,Emptyparam, Emptyparam,Emptyparam,Emptyparam,Emptyparam, Emptyparam)); //Einstellungen holen und setzen //worddocument2.PageSetup:= worddocument1.PageSetup geht leider nich, keine ahnung wieso nicht, kannst aber auch alles einzeln setzten worddocument2.PageSetup.LeftMargin := WordDocument1.PageSetup.LeftMargin; worddocument2.PageSetup.topMargin := WordDocument1.PageSetup.topMargin; worddocument2.PageSetup.RightMargin := WordDocument1.PageSetup.rightMargin; worddocument2.PageSetup.bottomMargin:= WordDocument1.PageSetup.bottomMargin; worddocument2.PageSetup.PageWidth := WordDocument1.PageSetup.PageWidth; worddocument2.PageSetup.PageHeight := WordDocument1.PageSetup.PageHeight; //...restliche eigenschaften
//doc wieder schliesen WordDocument1.Close; WordDocument1.Disconnect;
//Dok wieder in Vordergrund holen und datei einfügen WordDocument2.Activate; Selection.InsertFile(s,emptyparam,emptyparam,emptyparam,emptyparam); WordDocument2.Disconnect;
end; end; |