Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Shape formating (2003)

    I'm trying to create a shape, rename, resize and reposition on the current page. Any ideas.

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

    Re: Shape formating (2003)

    Try recording a macro. The generated code will not be the most efficient, but it will give you an idea of the code needed for this. (I assumed that you wanted VBA code)

  3. #3
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shape formating (2003)

    It wont record the name changes to the shape(checkbox)

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

    Re: Shape formating (2003)

    Perhaps not surprisingly, you can use the Name property of a Shape object.

  5. #5
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shape formating (2003)

    I can't seem to make it create the new shape on the current page rather than the top of the document. I'm using the attached.
    Attached Files Attached Files

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

    Re: Shape formating (2003)

    Try changing
    .AddOLEControl(ClassType:="Forms.CheckBox.1")

    to
    .AddOLEControl(ClassType:="Forms.CheckBox.1", Anchor:=Selection.Range)

    StuartR

  7. #7
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shape formating (2003)

    Works well. I'm trying to stack this to create 4 check-shapes. The only difference between the four is the name and left position. Can you think of another way to do this. Perhaps with a loop. Stacking these is causing some problems with word.

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

    Re: Shape formating (2003)

    Stack?

    What about this:

    Dim i As Integer
    For i = 1 To 4
    With ActiveDocument.Shapes.AddOLEControl( _
    ClassType:="Forms.CheckBox.1", _
    Anchor:=Selection.Range)
    .Width = 12
    .Height = 9
    .Top = -52.2
    .Left = 72 * i
    .OLEFormat.Object.Value = False
    .Name = "aud" & i
    End With
    Next i

  9. #9
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shape formating (2003)

    I was stacking the attached code to get four check-shapes. It's really close to what i'm looking for. I'll work on it for awhile before asking another dumb question.

  10. #10
    Star Lounger
    Join Date
    Apr 2003
    Location
    Washington, District Of Columbia, USA
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shape formating (2003)

    HansV i'm using the attached code. It rarely works and most times hangs Word up. I'm running this sub after another macro which finishes with a save. If it didn't hang up word it would be perfect. Any suggestions?
    Attached Files Attached Files

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

    Re: Shape formating (2003)

    It's not entirely clear what you want to do. If you want to add check boxes to each section, you should change

    fcount = ActiveDocument.Sections.Count

    to

    fcount = Selection.Information(wdActiveEndSectionNumber)

    otherwise, the code will try to assign the same names to the check boxes regardless of which section the selection is in when the macro is run. You can use Select Case ... End Select to streamline the code a bit - see attached version.
    Attached Files Attached Files

Posting Permissions

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