Reputation: 1483
I have a piece of code where as part of some event handling I am selecting an image in a word document and copying it in a file. But after the event handler is done, the image is shown as selected when I return back to word after the event has been handled. The code snippet is as follows :
foreach (Word.InlineShape shape in shapes)
{
string filepath = "somepath";
shape.Select();
Word.Application application = Globals.ThisAddIn.Application;
application.Selection.CopyAsPicture();
Computer comp = new Computer();
Image image = comp.Clipboard.GetImage();
image.Save(filepath, System.Drawing.Imaging.ImageFormat.Jpeg);
comp.Clipboard.Clear();
}
I want that this shape should not be shown as selected because the shape selection was only part of some event handling.
Is there a way to deselect this shape.
Thanx for your suggestions.
Upvotes: 3
Views: 3229
Reputation: 17278
You deselect the current selection by using
application.Selection.Collapse()
Upvotes: 6