#しつこいようだけど
[Visual Basic プロジェクトへのアクセスを信頼する]必要あり。
Sub try() '「WebBrowserを20コ配置したUserFormを作成」するコード
Const vbext_ct_MSForm As Long = 3
Const mgn As Single = 2 '調整余白
Const w As Single = 100 'WebBrowser.Width|Height
Const h As Single = 20 'CommandButton.Height
Dim iw As Single
Dim ih As Single
Dim i As Long
On Error GoTo extLine
With ActiveWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)
iw = .Properties("Width") - .Properties("InsideWidth")
ih = .Properties("Height") - .Properties("InsideHeight")
.Properties("Width") = iw + mgn + w + mgn
.Properties("Height") = ih + mgn + w + mgn + h + mgn
With .Designer.Controls
For i = 1 To 20
With .Add("Shell.Explorer.2")
.Left = mgn
.Top = mgn
.Width = w
.Height = w
End With
Next
With .Add("Forms.CommandButton.1")
.Left = mgn
.Top = mgn + w + mgn
.Width = w
.Height = h
End With
End With
End With
extLine:
With Err()
If .Number <> 0 Then
MsgBox .Number & "::" & .Description
End If
End With
End Sub
■UserForm作成コードで既出。
#一応、次回記事のネタフリで :D
[Visual Basic プロジェクトへのアクセスを信頼する]必要あり。
Sub try() '「WebBrowserを20コ配置したUserFormを作成」するコード
Const vbext_ct_MSForm As Long = 3
Const mgn As Single = 2 '調整余白
Const w As Single = 100 'WebBrowser.Width|Height
Const h As Single = 20 'CommandButton.Height
Dim iw As Single
Dim ih As Single
Dim i As Long
On Error GoTo extLine
With ActiveWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)
iw = .Properties("Width") - .Properties("InsideWidth")
ih = .Properties("Height") - .Properties("InsideHeight")
.Properties("Width") = iw + mgn + w + mgn
.Properties("Height") = ih + mgn + w + mgn + h + mgn
With .Designer.Controls
For i = 1 To 20
With .Add("Shell.Explorer.2")
.Left = mgn
.Top = mgn
.Width = w
.Height = w
End With
Next
With .Add("Forms.CommandButton.1")
.Left = mgn
.Top = mgn + w + mgn
.Width = w
.Height = h
End With
End With
End With
extLine:
With Err()
If .Number <> 0 Then
MsgBox .Number & "::" & .Description
End If
End With
End Sub
■UserForm作成コードで既出。
#一応、次回記事のネタフリで :D