难道没有一个知道吗?还是分不够,分不够我可以加的呀! (50分)

  • 主题发起人 progrand
  • 开始时间
P

progrand

Unregistered / Unconfirmed
GUEST, unregistred user!
如何用代码实现将剪切板的内容粘贴到word中并重新全选再复制回剪切板???
这样做的目的是交将网页的内容(有图片和文字,表格)完整的粘贴到rxrichedit上去,
如果直接用复制。粘贴的话就只有文字了!所有只好通过word的剪切板来实现了,不知
各位大侠可有什么好主意!
 
先用word打开这个网页,再selectAll,复制,到rxRichEdit里粘贴。
 
这个谁不会呀!
 
uses comobj;
var
word_hand, word_doc,word_selection, temp: olevariant;
begin
temp := EmptyParam;
try
word_hand := GetActiveOleObject('word.application');
except
try
word_hand := CreateOleObject('word.application');
except
exit;
end;
end;

word_hand.visible := true;
word_doc := word_hand.Documents.Add(temp, temp);
word_selection := word_hand.Selection ;

word_selection.typetext('Line');
word_selection.moveleft(unit:=wdCharacter,count:=4);
word_selection.moveright(unit:=wdCharacter,count:=4,extend := wdExtend);
word_selection.copy ;
word_selection.movedown(unit := wdLine,count:=2);
word_selection.typeparagraph;
word_selection.Paste ;
end;
 
你要干什么?考来考去的。
 
h:是目的句丙
SendMessage(h, EM_SETSEL, 0, -1);
sleep(50);
SendMessage(h, WM_COPY, 0, 0);
sleep(50);
****iguanli.F_shitiguanli.RxDBRichEdit_shiti.PasteFromClipboard;
 
你的意思是不是用word作为中介,而将网页上的东东,copy到RxRichEdit去,
若是如此,我可以给你解决。
 
linsb:你说的没错,我正是这个意思,你有什么方法可以解决这个问题吗?不胜感激!
 
创建word新文档,将剪切板内容copy到word,选择该内容,copy到RxRichEdit中,
思路如此,如思路接受又需要我给你编码,请说明,再贴。
 
linsb:我觉得你的思路非常可行,但是我希望你能提供更加详细的资料(如有代码则更好),谢谢!
 
procedure TForm1.startClick(Sender: TObject);
var
Template,NewTemplate,ItemIndex,DocumentType,Visible:OleVariant;
begin
try
WordApp.Connect;
except
MessageDlg('Word可能没有安装!', mtError, [mbOk], 0);
Abort;
end;
WordApp.Connect;
WordApp.Visible := false;
Template := EmptyParam;
NewTemplate := false; //True;
DocumentType:=$00000001;
Visible:=true;
ItemIndex := 1;
WordApp.Documents.Add(Template, NewTemplate,DocumentType,Visible);
WordDoc.ConnectTo(WordApp.Documents.Item(ItemIndex));
WordApp.Options.CheckSpellingAsYouType := False;
WordApp.Options.CheckGrammarAsYouType := False;
wordapp.Selection.Paste;
wordapp.Selection.WholeStory;
wordapp.Selection.Copy;
Editor.PasteFromClipboard;//TRxRichEdit
end;
//含图象的copy速度要慢
 
linsb:问题解决了,谢谢你了!
 
顶部