[resolved]office2002 vs office2003
Hi
I have a strange problem that I can't resolve it, so that's why after googling around I landed at this page that I think is efficient enough for such kind of problems:
I have the following macro which is acting differently in office 2002 and office 2003. Here is the macro:
Sub insertAnImage()
Dim pic As Shape
Set pic = ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, FileName:= _
"I:\vb\aPic.jpg")
With pic.WrapFormat
.AllowOverlap = True
.Type = 3 'wdWrapnone
End With
End Sub
in Word 2002:
when i position the cursor in the beginnig of a line and run this macro, the image will be inserted behind the text, that is what I intended to do!
in Word 2003:
doing the same thing here the image will be inserted on the text, so the text stays behind the image!!!
I really don't know from where it comes, is it a bug of office 2003, or is there any configuration to be made??? I hope you guys can help.
Re: office2002 vs office2003
I think this is due to the default settings in Word 2003. You can either go to tools - options - edit and set "Insert/paste pictures as" behind text or change your code to:
VB Code:
Sub InsertAnImage()
Dim pic As Shape
Set pic = ActiveDocument.Shapes.AddPicture(Anchor:=Selection.Range, FileName:= _
"I:\vb\aPic.jpg", LinkToFile:=False, SaveWithDocument:=True)
With pic
With .WrapFormat
.AllowOverlap = True
.Type = 3
End With
.ZOrder 5
End With
End Sub
I'm using Word 2003 and this seems to work fine, although you'll have to test it in Word 2002.
Hope this helps.
Re: office2002 vs office2003
thanx alot NEW2VBA,
both ways work, you were a great HELP!