• Macro for formatting a picture (Word 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Macro for formatting a picture (Word 2000)

    Author
    Topic
    #381598

    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

    Viewing 1 reply thread
    Author
    Replies
    • #644054

      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.

    • #644061

      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

      • #644155

        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!

        • #644219

          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

    Viewing 1 reply thread
    Reply To: Macro for formatting a picture (Word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: