Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Word
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?
 
ThanksSmile | :)
Posted 3-May-11 21:15pm
2000 P569
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 4 May 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100