I want to paste some text in clipboard into Ms Word. I wrote this following code


and it didn't work.

But i wrote the code below to paste into Wordpad,and it works fine


Am I made some mistake in Ms Words' window structure? The structure above is what i got using Winspector.I'm currently using Ms Word 2007.

Does anyone have solution?


Recommended Answers

All 2 Replies

I don't use Word, so I can't help... but what you are doing is unlikely to work well anyway because the window class names can change between versions of Word... But I think you should be looking for a RichEdit class...

I think you ought to look at OLE automation.
Here's a page all about word

Search down near the bottom in "How to automate word" for "paste".

The other option would be to send the proper keyboard sequences to Word to access the Edit|Paste menu item.

Sorry I can't be of more help.

I've found a solution in Word VBA reference:

V := GetActiveOleObject('Word.Application');

All i have to do is to check whether the foreground window is Ms Word or not, using GetClassName and GetForegroundWindow.

Problem solve. After all, thanks to you guys...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.