Click here to Skip to main content
13,048,406 members (143,692 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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?

Posted 3-May-11 20:15pm
2000 P574
Rate this: bad
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.[^]
Rate this: bad
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 4 May 2011
Copyright © CodeProject, 1999-2017
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