Hi,
Ok, so here's what I'm trying to do. Using code in Excel from the object "ThisWorkbook", create a new instance of a Word doc and then copy a picture (.jpg) that has been inserted into Sheet2 of said workbook and paste it into the newly created Word doc as an InLineShape. Reason is I don't want to hard code a file path using InLineShape.AddPicture(filepath), which otherwise works perfectly for me.
I've adapted my code to this so far (note: This isn't the complete code. There's a lot before and after this, but this section is unaltered other than added comments):
It works ok, except that after scaling the picture, there is a gray "void" left on the page and I can select a picture rectangle right next to it that is the size of the original Shape picture. Yet, adding in the line "appWD.ActiveDocument.Shapes(1).Delete" returns an error:
Invalid procedure call or argument
So... my question is, is there a simpler way to Copy a shape from an Excel spreadsheet and paste it into a Word doc as an InLineShape than what I'm doing? If not, what am I missing to clear out the remnants of the original picture paste job?
Ok, so here's what I'm trying to do. Using code in Excel from the object "ThisWorkbook", create a new instance of a Word doc and then copy a picture (.jpg) that has been inserted into Sheet2 of said workbook and paste it into the newly created Word doc as an InLineShape. Reason is I don't want to hard code a file path using InLineShape.AddPicture(filepath), which otherwise works perfectly for me.
I've adapted my code to this so far (note: This isn't the complete code. There's a lot before and after this, but this section is unaltered other than added comments):
Code:
With .Selection 'from "With appWD" where appWD is the Word doc
.Font.Size = 14
Sheet2.Shapes(1).Copy 'where the picture is
.Paste
Set shapeInline = appWD.ActiveDocument.Shapes(1).ConvertToInlineShape
shapeInline.ScaleHeight = 40
shapeInline.ScaleWidth = 40
Invalid procedure call or argument
So... my question is, is there a simpler way to Copy a shape from an Excel spreadsheet and paste it into a Word doc as an InLineShape than what I'm doing? If not, what am I missing to clear out the remnants of the original picture paste job?