我下面的代码给出了一个错误
Set VM = AP.VBProject.VBComponents("ViewManager").Designer.Controls
我查看了许多工作代码的示例,但无法弄清楚我的设置如何不同以导致错误。
错误是Run-time error '91': Object variable or With block variable not set
谢谢你的帮助。
Private Sub btnAdd_Click()
Dim View As String
Dim FField As String
Dim TField As String
View = cmbView.Value
FField = cmbFrmFld.Value
TField = cmbToFld.Value
'if it is the first add change one way, if after the first add change another
If ViewManager.Height = 116 Then
ViewManager.Height = ViewManager.Height + 64.5
ElseIf frmViews.Height > 116 Then
ViewManager.Height = ViewManager.Height + 30
End If
Dim AP As Project
Set AP = ActiveProject
Dim lbl As MSForms.Label
Dim VM As Object
Set VM = AP.VBProject.VBComponents("ViewManager").Designer.Controls
With VM
Set lbl = .Add("Forms.Label.1")
End With
With lbl
.Left = 6
.Top = ViewManager.Height - 32
.Width = 156
.Caption = View
End With
End Sub