title: Resize Userform and its Controls with VBA
body: <p>I am trying to resize a userform and its controls with VBA in order to accommodate different size monitors.  Following is the code I am using which is based on Ron DeBruin's code (<a href="http://www.rondebruin.nl/mac/mac022.htm" rel="nofollow">http://www.rondebruin.nl/mac/mac022.htm</a>).  </p>
  
  <p>In essence, the code is designed to scale the userform's size and location together with all of its controls.  </p>
  
  <p>The problem is I'm getting an error (shown below) on execution</p>
  
  <pre><code>"Run-time error '-2147467259(80004005)': Method 'Properties' of object '_VBComponent' failed"
  </code></pre>
  
  <p>I tried replacing <code>.Properties("Top")</code> with <code>.Top</code> and I got the <code>Object doesn't support this property or method</code> error.  </p>
  
  <p>Mr. DeBruin's code makes since; but I am at a loss as to why it is not working.  Any help would certainly be appreciated.</p>
  
  <pre><code>Sub ChangeUserFormAndControlsSize()
      Dim AppUserform As Object
      Dim FormControl As Object
      Dim NameUserform As String
      Dim SizeCoefficient As Single
  
      SizeCoefficient = wsControls.Range("SizeCoefficient")
  
      NameUserform = "form_APScheduler"
  
      Set AppUserform = ThisWorkbook.VBProject.VBComponents(NameUserform)
      With AppUserform
          .Properties("Top") = .Properties("Top") * SizeCoefficient   '*** ERROR OCCURS HERE
          .Properties("Left") = .Properties("Left") * SizeCoefficient
          .Properties("Height") = .Properties("Height") * SizeCoefficient
          .Properties("Width") = .Properties("Width") * SizeCoefficient
      End With
  
      For Each FormControl In AppUserform.Designer.Controls
          With FormControl
              .Top = .Top * SizeCoefficient
              .Left = .Left * SizeCoefficient
              .Width = .Width * SizeCoefficient
              .Height = .Height * SizeCoefficient
  
              On Error Resume Next
              .Font.Size = .Font.Size * SizeCoefficient
              On Error GoTo 0
          End With
      Next FormControl
  
  End Sub
  </code></pre>