OL 2000: 如何以编程方式创建一个窗体 http://support.microsoft.com/kb/238755/zh-cn

 

示例代码以将控件添加到窗体

下面的 Microsoft Outlook Visual Basic for Applications 代码演示了如何您可以以编程方式将一个 标签  列表框 控件添加到默认的联系人窗体的新页面。 一定要运行该代码之前,引用 Microsoft Forms 2.0 对象库。
Sub CreateForm()

   Dim oNewItem As Outlook.ContactItem
   Dim oInsp As Outlook.Inspector
   Dim oPage As Object
   Dim oLabel As MSForms.Control
   Dim oLB As MSForms.Control

   Set oNewItem = Application.CreateItem(olContactItem)
   Set oInsp = oNewItem.GetInspector

   ' Create a new form page called "My Page"
   Set oPage = oInsp.ModifiedFormPages.Add("My Page")

   ' Add the label to the form page
   Set oLabel = oPage.Controls.Add("Forms.Label.1", "lblCompanies", True)

   ' Size and position the label
   PlaceControl oLabel, 5, 10, 13, 100

   ' Set the caption of the label
   oLabel.Caption = "Companies:"

   ' Add the listbox to the form page
   Set oLB = oPage.Controls.Add("Forms.ListBox.1", "cmdCompanies", True)

   ' Size and position the listbox
   PlaceControl oLB, 18, 10, 50, 100

   ' Populate the listbox
   oLB.AddItem "Microsoft"
   oLB.AddItem "ACME"
   oLB.AddItem "Northwind"

   ' Change the form page so it defaults to "My Page"
   oInsp.SetCurrentFormPage "My Page"

   oNewItem.Display

   ' Clean up
   Set oListBox = Nothing
   Set oLabel = Nothing
   Set oPage = Nothing
   Set oInsp = Nothing
   Set oNewItem = Nothing

End Sub


Sub PlaceControl(Ctrl As MSForms.Control, T As Integer, _
                 L As Integer, H As Integer, W As Integer)
   Ctrl.Top = T
   Ctrl.Left = L
   Ctrl.Height = H
   Ctrl.Width = W
End Sub
				
此代码示例只是显示一个新创建的窗体,窗体。 有关如何以编程方式创建和发布一个新的自定义窗体的其他信息,单击下列文章编号以查看 Microsoft 知识库中相应的文章:
208520  OL2000: programming examples for referencing items and folders
请参阅相应的文章中的 Items.Add  CreateItemFromTemplate 方法。

回到顶端

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值