AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

OleContainer Copy

Ein Thema von danten · begonnen am 20. Sep 2016 · letzter Beitrag vom 20. Sep 2016
Antwort Antwort
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#1

OleContainer Copy

  Alt 20. Sep 2016, 07:42
Please how can I copy selected text from a Word document in Edit.
The code below is not working.

Thank you

Delphi-Quellcode:
olecontainer1.OleObject.ActiveWindow.Selection.Copy;
  Edit1.Clear;
  Edit1.PasteFromClipboard;
Daniel
  Mit Zitat antworten Zitat
HolgerX

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

AW: OleContainer Copy

  Alt 20. Sep 2016, 09: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
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#3

AW: OleContainer Copy

  Alt 20. Sep 2016, 12:20
[QUOTE=HolgerX;1348141]using COM:

Perfect, thank you
Daniel
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:09 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz