ms word - How to write a VBA script to insert, move and text wrap an image -


i making vba script generate default pages template document, going except when try insert image right aligned , text wrapped. used vba many years ago excel not sure how structure vba script. started making vba script image later integrated can find below.

what want achieve vba script

  • for insert image file within same directory template file (do have put full path or can put truncated 1 specify in same directory?)
  • for inserted image square text wrapped (default distances)
  • for image aligned left margin relative line have inserted in
  • the height of image @ 200 x 150

would kindly able elaborate on mwe have below. thank you:

sub insert_picture() ' ' insert_picture macro '      dim imagepath string     imagepath = "c:\users\edoardo\documents\my work\phd\skydrive\tutoring\houria\image replacement.jpg"      activedocument.shapes.addpicture filename:=imagepath, _     linktofile:=false, _     savewithdocument:=true, _     left:=-5, _     top:=5, _     anchor:=selection.range, _     width:=200, _     height:=150      imagepath         .wrapformat.type = wdwrapsquare     end end sub 

i worked out in end follows:

sub insert_sqwrap_image()     dim shp shape     set shp = activedocument.shapes.addpicture( _         filename:="c:\users\edoardo\documents\my work\phd\skydrive\tutoring\houria\image replacement.jpg", _         savewithdocument:=true, _         anchor:=selection.range)     shp         .wrapformat.type = wdwrapsquare         .left = 246         .top = 50         .width = 250         .height = 188     end end sub 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -