We help IT Professionals succeed at work.
Get Started

Help with Word VBA sub

Last Modified: 2013-11-25
I've got a sub that works ok, but I'm unsure about the syntax. Therefore I'm not sure that the sub will continue to work once installed in the Normal.NewMacros.doc in an end user workstation. I need to know how to identify the Picture number of any picture in a Word doc. Is there a way? Can a Picture number be set as a variable? My sub goes out and grabs a jpg file in a fixed location and inserts it as a picture into the active document. Then it aligns the picture inside the frame of another picture already in the document.
Sub InsertPicture()
Application.ScreenUpdating = False
Dim Doc As Word.Document

Dim PicFile As String

Set Doc = ActiveDocument

PicFile = "\\domain-01.com\dfs$\care-one\users\care-one_nanthony\desktop\Smuckers\IMG.jpg"

Doc.Shapes.AddPicture _
FileName:=PicFile, _
LinkToFile:=False, _

    ActiveDocument.Shapes("Picture 24").Select
    Selection.ShapeRange.IncrementLeft 144#
    Selection.ShapeRange.IncrementTop 7.85

Application.ScreenUpdating = True

End Sub

Open in new window

Watch Question
Top Expert 2012
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE