Option Explicit
Private Sub UserForm_Activate()
Dim FormControl As Control, N&
DoEvents
Application.ScreenUpdating = False
On Error GoTo AddSnapShot
Sheets("SnapShot").Activate
SheetExists:
Cells.ClearContents
[A1] = "Control"
[B1] = ".Height"
[C1] = ".Width"
[D1] = ".Top"
[E1] = ".Left"
With [A2]
.Offset(0, 0) = Me.Name
.Offset(0, 1) = Me.Height
.Offset(0, 2) = Me.Width
.Offset(0, 3) = Me.Top
.Offset(0, 4) = Me.Left
N = 1
For Each FormControl In Controls
.Offset(N, 0) = FormControl.Name
.Offset(N, 1) = FormControl.Height
.Offset(N, 2) = FormControl.Width
.Offset(N, 3) = FormControl.Top
.Offset(N, 4) = FormControl.Left
N = N + 1
Next FormControl
End With
Rows(1).Font.Bold = True
Columns(1).Font.Bold = True
With Cells
.Columns.AutoFit
.Rows.AutoFit
.HorizontalAlignment = xlLeft
End With
Unload Me
Exit Sub
AddSnapShot:
ActiveWorkbook.Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "Snapshot"
Resume SheetExists
End Sub
Option Explicit
Sub ShowForm()
UserForm1.Show False
End Sub
|