Defining the top and bottom measurement of an inserted image.

C

Colinhp

I have this code in a global template to set how an image is inserted:

Options.PictureWrapType = wdWrapMergeTopBottom

I want the top and bottom settings to be set to 0.2cm each.
How do I add this to this code string?
 
S

Shauna Kelly

Hi Colin

This code is changing the user's general settings for how pictures are
inserted. It's not generally good practice to do that (if your code changed
*my* settings I'd be very very cross!).

Post us the code that actually inserts the image and we can see how to set
the top and bottom settings.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
C

Colinhp

Hello Shauna,

The template includes code to set the users environment for the company
template. One of the layout consistencies we have is for most pictures to
have text 'top and bottom'. When the global template is closed by the user
(say when they close a document created from the template for example) their
settings are reset to before the template was opened.
This is where I want to have the settings set so there is a 0.2cm gap at the
top and bottom of any inserted picture. I can see how this is done via the
Wrapping dialogue box when inserting pictures, but want to automate this for
the user.
Below is the code used when a new document is created.

Application.TaskPanes(wdTaskPaneStylesandFormatting).Visible = True
Options.CheckSpellingAsYouType = True
Options.PictureWrapType = wdWrapMergeTopBottom
ActiveDocument.ShowSpellingErrors = True

Thank you,

Colin.
 
A

Astrid

Hi Colin,

A global template usually means an addin which should override all the user
settings, I think that was what Shauna thought of when you described it as
such.

For another template however, it is not a strange idea to set the wrapformat
of course. However, I don't think it is possible to set the default
textmargin between picture and text for all the pictures.
If you really want to archieve something like this, you should write your
own code that inserts the picture.

Something like:
------------------------------------------------------------------------------------------------------
Sub InsertPicture()
Dim oShape As Shape

With Dialogs(wdDialogInsertPicture)
If .Display Then
'User pressed OK button
Set oShape = ActiveDocument.Shapes.AddPicture(FileName:=.Name,
Anchor:=Selection.Range)
With oShape
.WrapFormat.Type = wdWrapTopBottom
.WrapFormat.DistanceBottom = CentimetersToPoints(0.2)
.WrapFormat.DistanceTop = CentimetersToPoints(0.2)
End With
End If
End With

Set oShape = Nothing

End Sub
------------------------------------------------------------------------------------------------------

Name the macro InsertPicture will override the default Word command.


Hope this helps,
kind regards,

Astrid
 
C

Colinhp

Hello Astrid,

Many thanks for your help on this. Your solution works a treat.

Cheers,

Colin.
 

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