Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Picture Word 2003 VBA

Status
Not open for further replies.

JasonEnsor

Programmer
Sep 14, 2010
193
GB
Hey,

I am slowly getting the desired results i want out of a new template i am creating (Thanks to help from people on here). My current problem is i have a custom toolbar that has the insert picture attached to it, however i want the pictures that are inserted to automatically be centered and for a blank line to be inserted after the picture is placed. As the user will be using several pictures it's not possible for me to hardcode the names in to vba.

Any ideas on the best way of doing this, i thought if i could create a new macro that could open the insert picture box, format the picture and then put the blank line in that would work, i just don't know where to start.
 
Not quite following, but it may be the case where you can use a style.

I do this. I have a style named "ImageHolder". It is centered, and has a following space of 14 pts (so it has a nice space between it and the following text.

Generally speaking it is a bad idea to have "blank lines" anyway. I do not know what you have attached code-wise to your icon on your toolbar, but you could have it insert the style first, THEN call up the insert picture dialog. Like this:
Code:
Sub InsertMyPicture()
   Selection.Style = ActiveDocument.Styles("ImageHolder")
   Application.Dialogs(wdDialogInsertPicture).Show
End Sub
The procedure makes the current paragraph (th eone the cursor is on), the ImageHolder style (centered with a following space of 14pts), and then shows the InsertPicture dialog.

The user can use the dialog to find whatever pictur ethey want, clicks Insert and it is inserted with the appropriate before and following space - no "blank line".

BTW: I put "blank lines" in quotes because...there is no such thing as a blank line. At least not if it is terminated by a paragraph mark.


unknown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top