Results 1 to 4 of 4

Resize buttons to cell

Threaded View

  1. #1
    Registered User
    Join Date
    01-27-2010
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    5

    Resize buttons to cell

    Hi All,

    I've got a couple of sheets with a lot of buttons in them. Some of these buttons have the wrong dimensions. What I want to do is run a macro so that every button gets the same dimensions as a given cell. I've found the following macro:

    Sub ButtonSize_as_CellSize()
    
    Dim s1 As String
    Dim I1 As String
    Dim w As Double
    Dim h As Double
    
    s1 = "Sheet1"   'name of sheet you wish to use...
    Sheets(s1).Select
    
    10:
    E = 0
    I1 = Application.InputBox("Which Cell Do You wish to use as size template?  Enter as cell ref = ie A1", "Cell Dimension", "A1")
    On Error GoTo InvalidRange
    With Range(I1)
        w = .Width
        h = .Height
    End With
    If E = 1 Then GoTo 10
    
    Dim obj As Object
    For Each obj In ActiveSheet.OLEObjects
    If obj.OLEType = 2 Then
        With obj
            .Width = w
            .Height = h
        End With
    End If
    Next obj
    
    Exit Sub
    
    InvalidRange:
    MsgBox "Invalid Cell Reference Entered", vbCritical, "Error"
    E = 1
    Resume Next
    
    End Sub
    But this doesn't do anything (no error, but also no changes). If I step through the macro it jumps from line "For Each obj In ActiveSheet.OLEObjects" to line "Exit Sub". So it seems there are no OLEObjects in the sheet. But there are about 100 buttons in the sheet.

    Could a button be anything else than an OLEObject? And if so, is there a way I can change this macro to do what I want it to do?
    Last edited by romperstomper; 06-20-2011 at 09:46 AM. Reason: Mark solved

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