how to put pics to certain position with VBA?

liujw
liujw used Ask the Experts™
on
I want to put one pic to left 0 top 0 of page 1,
and another to left0 top0 of page2,
thx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

Commented:
Are you speaking of m$Word ?

Author

Commented:
yes
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
This is the macro i recorded with word 2000:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/21/2002 by guy
'
  Selection.InlineShapes.AddPicture FileName:= _
    "E:\Documents and Settings\page1.jpg", _
    LinkToFile:=False, SaveWithDocument:=True
 
  Selection.InsertBreak Type:=wdPageBreak
 
  Selection.InlineShapes.AddPicture FileName:= _
    "E:\Documents and Settings\page2.jpg", _
    LinkToFile:=False, SaveWithDocument:=True
End Sub

How far does that work for you?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
i created a template doc3.DOT,and already put some words inside including wdPageBreak and Bookmark,here is some of my code:

Selection.GoTo What:=wdGoToBookmark, Name:="bkg2"
Set oShape2 = ActiveDocument.Shapes.AddPicture(FileName:="E:\PM\vba2\life_01.tif", _
        LinkToFile:=False, SaveWithDocument:=True)
oShape2.Select
ActiveWindow.ActivePane.VerticalPercentScrolled = 25
    Selection.ShapeRange.Fill.Visible = msoFalse
    Selection.ShapeRange.Fill.Transparency = 0#
    Selection.ShapeRange.Line.Weight = 0.75
    Selection.ShapeRange.Line.DashStyle = 1
    Selection.ShapeRange.Line.Style = 1
    Selection.ShapeRange.Line.Transparency = 0#
    Selection.ShapeRange.Line.Visible = msoFalse
    Selection.ShapeRange.LockAspectRatio = msoTrue
    Selection.ShapeRange.Height = 778.4
    Selection.ShapeRange.Width = 550.5
    Selection.ShapeRange.PictureFormat.Brightness = 0.5
    Selection.ShapeRange.PictureFormat.Contrast = 0.5
    Selection.ShapeRange.PictureFormat.ColorType = 1
    Selection.ShapeRange.PictureFormat.CropLeft = 0#
    Selection.ShapeRange.PictureFormat.CropRight = 0#
    Selection.ShapeRange.PictureFormat.CropTop = 0#
    Selection.ShapeRange.PictureFormat.CropBottom = 0#
    Selection.ShapeRange.RelativeHorizontalPosition = _
        wdRelativeHorizontalPositionColumn
    Selection.ShapeRange.RelativeVerticalPosition = _
        wdRelativeVerticalPositionParagraph
    Selection.ShapeRange.Left = CentimetersToPoints(0)
    Selection.ShapeRange.Top = CentimetersToPoints(0)
    Selection.ShapeRange.LockAnchor = False
    Selection.ShapeRange.WrapFormat.AllowOverlap = True
    Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
    Selection.ShapeRange.WrapFormat.DistanceTop = CentimetersToPoints(0)
    Selection.ShapeRange.WrapFormat.DistanceBottom = CentimetersToPoints(0)
    Selection.ShapeRange.WrapFormat.DistanceLeft = CentimetersToPoints(0.32)
    Selection.ShapeRange.WrapFormat.DistanceRight = CentimetersToPoints(0.32)
    Selection.ShapeRange.WrapFormat.Type = 3
    Selection.ShapeRange.ZOrder msoSendBehindText

Author

Commented:
the problem is :
page 1 is ok,
but page2 , the pic be put into page1,
help!
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

Commented:
You must have the selection object to point to the "first" character on the second page (this is why i had inserted a page break after the first image).

Author

Commented:
i have insert a PageBreak at the end of first page

Author

Commented:
in the template file i have insert a PageBreak at the end of the first page

Author

Commented:
in the template file i have insert a PageBreak at the end of the first page

Author

Commented:
the bookmark "bkg2" is the "first" character

Author

Commented:
i think the problem in this line:
Set oShape2 = ActiveDocument.Shapes.AddPicture(FileName:="E:\PM\vba2\life_01.tif", _
       LinkToFile:=False, SaveWithDocument:=True)

but i really don't know why
Author of the Year 2009

Commented:
Hi liujw,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept angelIII's comment(s) as an answer.

liujw, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.
==========
DanRollins -- EE database cleanup volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial