Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Dec 2000
    Location
    Montreal, Quebec, Canada
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro for formatting a picture (Word 2000)

    Hello gang,
    I am trying to create a macro that will insert a picture, resize it and place it where I want on a page. Since I am not a programmer, I record the steps as I make them. When I get to the layout section in format picture, all the options are dimmed. I cannot access them just by recording. Can someome tell me how I could "code" the layout section of the format picture dialog box.

    Thanks
    jc

  2. #2
    Star Lounger
    Join Date
    Jun 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro for formatting a picture (Word 2000)

    After inserting the graphic but before doing ANYTHING else,

    ' Select Newly Created Graphic
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

    This will select the newly inserted graphic. There's probably a better way but it works for me.
    Good luck with positioning the graphic on the page.

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macro for formatting a picture (Word 2000)

    Assuming that you insert the picture as an InlineShape then after the previously suggested
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    You can try
    With Selection.InlineShapes(1)
    .Height =
    .Width =
    etc.
    End With.

    An inline shape cannot be arbitrarily moved around the page.

    If you have inserted the picture as a Shape then it is probably selected already and you won't need the Selection.MoveLeft bit. You can now try
    With Selection.ShapeRange(1)
    .Height =
    .Width =
    .Left =
    .Right =
    etc.
    End With.

    Look up the properties of a Shape and an InlineShape in the VBA help file for other attributes that you might want to set, or ask again if you need more help.

    StuartR

  4. #4
    2 Star Lounger
    Join Date
    Dec 2000
    Location
    Montreal, Quebec, Canada
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro for formatting a picture (Word 2000)

    Change of plans but on the same set of thoughts: shapes.
    I have a document with sections and different pictures in the headers. I have one section for the cover page, one for the ToC and one for the text. I want to create a macro that will create a new section at the end of the doc that will have no pictures in the headers.
    I know how to get insert a section break and to tell it which section to work in:
    Dim i As Integer
    i = Selection.Information(wdActiveEndSectionNumber)
    I know how to change the margins, tabs and not same as previous in the primary and EvenPages headers and footers.
    What I can't seem to do is to delete the pictures in them. Since they are not in-line with text, I cannot just use Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend. It does not work.
    I tried:
    With .Headers(wdHeaderFooterPrimary)
    .Shapes(#).Delete
    It deletes some shapes but not necessarily the ones I want (i.e. deletes shapes in the previous sections also). I can't seem to find a pattern to which shape it decides to delete even after trying different shape numbers.
    I know I am not telling it exactly which shape I want to be deleted. I just can't figure out how to do this. I tried shaperange.name but I just don't get it.
    After 5 hours, I guess I am just tired.
    HELP!

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macro for formatting a picture (Word 2000)

    Firstly, make sure that you set the .LinkToPrevious property of the Header to False. This ensures that you only change the header for the new section.

    Where do the shapes you need to delete come from? What enables you to recognise them? When I need to do something similar I set the .Name property of the shapes at the time of inserting them, this makes it very easy to find and delete them later. The only alternative is to look at all members of the .ShapeRange collection and decide if this is the shape you want to delete based on Size, Colour, Shape, Type of Shape, ????, Position on the Page or some other property.

    StuartR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •