Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Is there any option to cut (Not Copy!) a picture from the word document and paste it again? Sample code I found in the google only helped for Copy and paste.
Could somebdy help me on this?

Thanks:)
Posted

You can use Win32 SendInput method, and direct your SendInput to Word.
Via SendInput you can tell that you what to press "CTRL", then "X" and release "X" and "CTRL", simulating a CTRL+X for Cut.

http://www.pinvoke.net/default.aspx/user32/sendinput.html[^]
 
Share this answer
 
Install Primary Interop Assemblies for whichever version of Office / Word you are using.
Add a reference to the Word PIA in your project.
You can now control Word directly from your C# code.
The structure of your code will be pretty much the same as if you'd written a VBA macro within Word itself - in VB.NET, even the syntax will be pretty close, but for C# you'll have to do a bit of editing.
So to get a quick start, go to Word, record a macro to do what you want and look at it.
Now replicate what it does in your C# code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900