Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Defining the top and bottom measurement of an inserted image.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Colinhp - 17 Nov 2006 13:19 GMT
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?
Shauna Kelly - 17 Nov 2006 23:01 GMT
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

>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?
Colinhp - 20 Nov 2006 08:26 GMT
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.

> Hi Colin
>
[quoted text clipped - 16 lines]
> > I want the top and bottom settings to be set to 0.2cm each.
> > How do I add this to this code string?
Astrid - 20 Nov 2006 10:39 GMT
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

> Hello Shauna,
>
[quoted text clipped - 45 lines]
>> > I want the top and bottom settings to be set to 0.2cm each.
>> > How do I add this to this code string?
Colinhp - 20 Nov 2006 12:05 GMT
Hello Astrid,

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

Cheers,

Colin.

> Hi Colin,
>
[quoted text clipped - 87 lines]
> >> > I want the top and bottom settings to be set to 0.2cm each.
> >> > How do I add this to this code string?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.