+ Reply to Thread
Results 1 to 4 of 4

Snap Object to cell borders

  1. #1
    Ed Schwartz
    Guest

    Snap Object to cell borders


    I'm writing an application where users will move around several
    objects (Label fields) on a worksheet

    1. How can I make the objects "snap" to the cell borders ?
    2. Is it possible to "link" two or more objets (on different worksheets)
    so that all "linked" objects are moved simultaneously if one of them
    is moved?

    Thanks a lot for any ideas or suggestions !

    Ed


  2. #2
    Jim Rech
    Guest

    Re: Snap Object to cell borders

    "Snapping" is accomplished by adjusting an object's Top and Left properties
    to those of the underlying cell:

    Dim x As Shape
    Set x = Sheet1.Shapes(1)
    x.Left = x.TopLeftCell.Left
    'etc

    No way to link the moving of objects. You'd have to write a macro to do
    that.

    --
    Jim
    "Ed Schwartz" <[email protected]> wrote in message
    news:[email protected]...
    |
    | I'm writing an application where users will move around several
    | objects (Label fields) on a worksheet
    |
    | 1. How can I make the objects "snap" to the cell borders ?
    | 2. Is it possible to "link" two or more objets (on different worksheets)
    | so that all "linked" objects are moved simultaneously if one of them
    | is moved?
    |
    | Thanks a lot for any ideas or suggestions !
    |
    | Ed
    |



  3. #3
    Ed Schwartz
    Guest

    Re: Snap Object to cell borders


    Thanks a lot, Jim - works very well !


    >
    > Dim x As Shape
    > Set x = Sheet1.Shapes(1)
    > x.Left = x.TopLeftCell.Left
    > 'etc
    >
    > No way to link the moving of objects. You'd have to write a macro to do
    > that.
    >



  4. #4
    Vic Eldridge
    Guest

    RE: Snap Object to cell borders


    > 1. How can I make the objects "snap" to the cell borders ?

    On Excel's Drawing toolbar, click Draw > Snap > To Grid.



    > 2. Is it possible to "link" two or more objets (on different worksheets)
    > so that all "linked" objects are moved simultaneously if one of them
    > is moved?

    If the shapes on sheet1 and sheet2 were given the same names on both sheets,
    you could use the following code to update their positions.

    'In Sheet1's code module
    Private Sub Worksheet_Activate()
    Dim shp As Shape
    For Each shp In Sheets("Sheet1").Shapes
    shp.Top = Sheets("Sheet2").Shapes(shp.Name).Top
    shp.Left = Sheets("Sheet2").Shapes(shp.Name).Left
    Next
    End Sub

    'In sheet2's code module
    Private Sub Worksheet_Activate()
    Dim shp As Shape
    For Each shp In Sheets("Sheet2").Shapes
    shp.Top = Sheets("Sheet1").Shapes(shp.Name).Top
    shp.Left = Sheets("Sheet1").Shapes(shp.Name).Left
    Next
    End Sub


    Regards,
    Vic Eldridge

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1