Darryl Bryk wrote:
Code to copy a graph:
using (MemoryStream mem = new MemoryStream()) {
cht.SaveImage(mem, ChartImageFormat.Bmp);
using (Bitmap bmp = new Bitmap(mem)) {
Clipboard.SetImage(bmp);
if (Clipboard.ContainsImage())
par.Range.Paste();
else throw new Exception("Clipboard.ContainsImage() failed");
}
}
I was almost sure that you're pasting the image instead of graph...
One way to fit image is to add an image into a cell of table. I'd suggest to use borderless table and change its default
AutoFitBehaviour
to
wdAutoFitWindow
. You can also try to use
wdAutoFitFixed
. Please see:
Table.AutoFitBehavior method (Word) | Microsoft Docs[
^]
Another solution is to use
TextFrame object (Word) | Microsoft Docs[
^].