Vba Excel picture pastes over text in outlook mail -
i new vba coding , i'm having issues macro. i'm trying copy range in excel picture outlook mail , add text in body well. however, code adding text , pasting picture on top of it. how can paste under text?
here's code:
dim outapp object dim outmail object dim myfilelist(1) string dim long set outapp = createobject("outlook.application") set outmail = outapp.createitem(0) set rngcopied = worksheets("daily volume summary").range("volumerange") myfilelist(0) = "y:xyz\sales.pdf" myfilelist(1) = "y:xyz\sales.xlsx" 'on error resume next outmail .to = "abc@xyz.com" .cc = "def@xyz.com" .bcc = "" .subject = "pbc daily sales " & format(date, "mm/dd/yyyy") .body = "good morning," & vbnewline & vbnewline & "attach daily sales report " & format(date, "dddd,mmmm,dd,yyyy") & "." & "<br>" 'copy range of interest dim r range set r = worksheets("daily volume summary").range("volumerange") r.copy 'get word editor outmail.display dim worddoc word.document set worddoc = outmail.getinspector.wordeditor 'to paste picture worddoc.range.pasteandformat wdchartpicture dim shp object each shp in worddoc.inlineshapes shp.scaleheight = 60 shp.scalewidth = 60 next = 0 ubound(myfilelist) .attachments.add myfilelist(i) next .send end on error goto 0 set outmail = nothing set outapp = nothing end sub
in line:
worddoc.range.pasteandformat wdchartpicture
you replacing entire range of message's word doc picture. instead need note in range want paste this. should put after text:
worddoc.range(start:=worddoc.range.end - 2).pasteandformat wdchartpicture
Comments
Post a Comment