PDA

View Full Version : How to copy a picture from Excel to word



Nils001
07-04-2015, 01:33 AM
Hello,

I have a table in Excel, which i have copied into a picture, rotated it and changed the size. Then i would like to copy to picture into word, but I have a bit trouble copying the picture from Excel into Word. I have been trying to use the code below (and others). It does only copy a tiny object into word, which is not the table. I am using office 2013.


'Insert benchmarkingtable
'copy graph
wbk3.Worksheets("LR_tabel").Shapes("B_tabel").Copy
'Go to bookmark
wdApp.Selection.Goto What:=Word.wdGoToBookmark, Name:="btabel"
'Insert graph in word
wdApp.Selection.PasteSpecial DataType:=Word.wdPasteDefault

This i how the picture is made, which works fine:


'copy the graph into a picture, rotate it and change the size
Range(wbk3.Worksheets("LR_tabel").Cells(1, 1), wbk3.Worksheets("LR_tabel").Cells(slut(5), 2 + antalKategorier)).Select
Selection.Copy
Range(wbk3.Worksheets("LR_tabel").Cells(slut(5) + 2, 1), wbk3.Worksheets("LR_tabel").Cells(slut(5) + 2, 1)).Select
wbk3.Worksheets("LR_tabel").Pictures.Paste.Name = "B_tabel"
wbk3.Worksheets("LR_tabel").Shapes.Range(Array("B_tabel")).Select
Selection.ShapeRange.IncrementRotation 90
Selection.ShapeRange.Width = Application.CentimetersToPoints(28)

Help will be very much appreciated!

Kenneth Hobs
07-04-2015, 10:59 AM
Did you look at the Shape B_tablel after you resized it in Excel? Did you add the MSWord reference so that Word.wdPasteDefault constant value was resolved? You can see if it resolved by putting this in the immediate window and press Enter key.

?Word.wdPasteDefault

If you like, stripout all but the resize picture and attach it if you still need help. You could also Zip and attach a sample MSWord file with the bookmark in it as well.

snb
07-05-2015, 04:16 AM
You can insert in Word any graph as link from any Excelfile manually.