+ Reply to Thread
Results 1 to 2 of 2

Center Align Image

Hybrid View

  1. #1
    Registered User
    Join Date
    05-14-2008
    Posts
    27

    Center Align Image

    Hello,

    I am positioning 36 images inside 36 cells.
    It is working but the images are top left aligned.
    How can I make them centered?

    Here is my code:
    ' Reposition
    Sub Reposition(ByRef game As GameType)
    
        ' Variables declaration
        Dim i As Integer, j As Integer, output As Range
        
        ' Define output
        Set output = Range("B3:G8")
        
        ' Reposition alghoritm
        For i = 1 To 6
            For j = 1 To 6
                With ActiveSheet.Shapes(game.Images(i, j))
                    .Left = output.Cells(i, j).Left
                    .Top = output.Cells(i, j).Top
                End With
            Next j
        Next i
        
    End Sub ' Reposition
    Thanks,
    Miguel

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    Use these revised Left and Top calculations to center shape

                    .Left = output.Cells(i, j).Left + ((output.Cells(i, j).Width - .Width) / 2)
                    .Top = output.Cells(i, j).Top + ((output.Cells(i, j).Height - .Height) / 2)
    Cheers
    Andy
    www.andypope.info

+ 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