Thema: Delphi OleContainer Copy

Einzelnen Beitrag anzeigen

HolgerX

Registriert seit: 10. Apr 2006
Ort: Leverkusen
969 Beiträge
 
Delphi 6 Professional
 
#2

AW: OleContainer Copy

  Alt 20. Sep 2016, 10:16
using COM:

Delphi-Quellcode:
uses
  ComObj;

procedure TForm1.Button1Click(Sender: TObject);
var
  WordApp : OleVariant;
  Doc : OleVariant;
  Sel : OleVariant;
begin


  WordApp := GetActiveOleObject('Word.Application'); // Connect to open Word
  try
    try
      Doc := WordApp.ActiveDocument;
      Sel := Doc.ActiveWindow.Selection;

      Edit1.Text := Sel.Text;
// or simple
      Edit1.Text := WordApp.ActiveDocument.ActiveWindow.Selection.Text;

    except
      WordApp.Visible := true;
    end;
  finally
    WordApp := Unassigned; // Disconnect
  end;
end;

You did't need the Clipboard!
  Mit Zitat antworten Zitat