Word Macro to insert and position picture to correct place in docu

D

D.Harper

I can get a picture inserted into my document with a macro. But, I need to
move where this picture places itself in my document. It automatically posts
centered, and I need it on the right side of my document. I can't do this
with auto text, I have to do it with a macro button on my toolbar.

Can anyone help with the code for resizing and moving a picture once it is
inserted in a document?
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RC5IYXJwZXI=?=,
I can get a picture inserted into my document with a macro. But, I need to
move where this picture places itself in my document. It automatically posts
centered, and I need it on the right side of my document. I can't do this
with auto text, I have to do it with a macro button on my toolbar.

Can anyone help with the code for resizing and moving a picture once it is
inserted in a document?
Show us the macro you've got so far, so that we can build on it?

Also, which version of Word do you have?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
D

D.Harper

Here is what I have that actually works:



Sub Macro3()
'
' Macro3 Macro
' Macro recorded 7/20/2006 by Delana Harper
'


With ActiveDocument.Bookmarks(1)

Selection.InlineShapes.AddPicture
FileName:="P:\dharper\GovOfficeTemplates\msoffice\signature\jer.jpg",
LinkToFile:= _
False, SaveWithDocument:=True

End With

End Sub
 
D

D.Harper

I have 2 versions of word. I have XP on my main computer and 2003 on my
secondary computer.
 
C

Cindy M -WordMVP-

Hi Delana,
Here is what I have that actually works:
OK, I'm going to interpret everything very literally: you're inserting a picture
inline with the text - this would mean text won't "flow" around the picture. One
line of text would align with the bottom of the picture, otherwise the text would
be above and below. (Or the picture could be in a line all by itself, with text
above and below). Is this what you want? If yes, if you click the "Right align"
paragraph button, the picture would move to the right.

If this isn't right, can you explain what commands you use on the result of
"Macro3" to make it look right?
Sub Macro3()
'
' Macro3 Macro
' Macro recorded 7/20/2006 by Delana Harper
'


With ActiveDocument.Bookmarks(1)

Selection.InlineShapes.AddPicture
FileName:="P:\dharper\GovOfficeTemplates\msoffice\signature\jer.jpg",
LinkToFile:= _
False, SaveWithDocument:=True

End With

End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail :)
 
D

D.Harper

Cindy,

I am inserting the picture between 2 lines at a bookmark. The document is a
letter, and the picture I want to insert is a signature. I have figured out
how to get the picture to insert at the bookmark. I have a couple of problems
though. If I insert the picture without referencing the bookmark, then it is
centered on the page. That is the code I already provided. If I insert the
picture at the bookmark, it will insert the bookmark and picture wherever my
cursor is currently placed in the document instead of where I have the
bookmark inserted. I can try the steps you mention below to move the picture
to the right, but I am wondering why the bookmark is moving instead of having
the picture insert at the correct place. Also, I need to change the picture
so that the signature (the content of the picture) is not hiding the rest of
the letter salutation.
Any suggestions on that?

Thanks for any help you can provide.

Delana
 
C

Cindy M -WordMVP-

Hi Delana,
I am inserting the picture between 2 lines at a bookmark. The document is a
letter, and the picture I want to insert is a signature. I have figured out
how to get the picture to insert at the bookmark. I have a couple of problems
though. If I insert the picture without referencing the bookmark, then it is
centered on the page. That is the code I already provided. If I insert the
picture at the bookmark, it will insert the bookmark and picture wherever my
cursor is currently placed in the document instead of where I have the
bookmark inserted. I can try the steps you mention below to move the picture
to the right, but I am wondering why the bookmark is moving instead of having
the picture insert at the correct place. Also, I need to change the picture
so that the signature (the content of the picture) is not hiding the rest of
the letter salutation.
OK, click in the empty paragraph where you have the bookmark. Right-align it (no
need to use macro code to do something you can pre-set in the document). Now all
that remains is to insert the file at the bookmark. Try this:

Sub InsertSigAtBookmark
Dim doc as Word.Document
Dim bkmName as String
Dim SigFile as String

Set doc = ActiveDocument
bkmName = "BookmarkName"
SigFile = "P:\dharper\GovOfficeTemplates\msoffice\signature\jer.jpg"
doc.InlineShapes.AddPicture :
FileName:=SigFile, _
LinkToFile:=False, _
SaveWithDocument:=True, _
Range:=doc.Bookmarks(bkmName).Range
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top