Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jun 2003
    Location
    Surrey, England
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting Autoshapes (Office XP Pro)

    I am trying to generate a Word doc out of VB code which will prepare the text and format of the Word doc. Essentially, I am trying to create an existing document from VB without using a template etc. The reasons are many, but this is my requirement.
    The original doc has some autoshapes in it - mostly lines - which I need this macro/VB to generate. I cannot see if this is possible. I have tried recording a macro to see what the editor would create and autoshapes seem to be unusable.
    Can anyone confirm I am scuppered here, or if not, give me a clue as to how I could do this?
    As an example, I have a Header for all pages - it has some text and a nice line across the width of the header created from an autoshape - a simple line! So from VB, I can create the Header, put in and format the text, but the autoshape line does not seem possible.
    Help?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Inserting Autoshapes (Office XP Pro)

    Look up the AddLine method of the Shapes collection. Example:

    Dim shpLine As Shape
    Set shpLine = ActiveDocument.Sections(1).Headers(wdHeaderFooterP rimary).Shapes.AddLine(144, 10, 504, 10)

    The numbers are top, left, bottom, right, measured in points (72 points = 1 inch) from the anchor of the line. Similar methods exist for other AutoShape objects.

  3. #3
    New Lounger
    Join Date
    Jun 2003
    Location
    Surrey, England
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting Autoshapes (Office XP Pro)

    Hans,

    A very big thanks for this - exactly what I was after. Can't believe I missed it.....

    Ken.

  4. #4
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Inserting Autoshapes (Office XP Pro)

    As an aside to using AutoShapes.

    I too like to use lines to delimit headers and footers.

    What I do is to use the Paragraph Formatting Borders and Shading function to add a line border to either the top or bottom of the paragraph. I find this easier than drawing lines.

    Regards,
    Kevin Bell

Posting Permissions

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