【问题标题】:Unable to Pass Value from Userform to Module无法将值从用户窗体传递到模块
【发布时间】:2018-11-04 09:33:37
【问题描述】:

所有,我正在尝试将选定项目(或多个项目)的值从用户窗体传递到 ThisOutlookSession,但无法传递字符串。感谢您对我可能出错的地方的想法。

这个想法是用一个 txt 文件中的引用列表填充一个列表框(这工作正常),用户将从列表框中选择一个项目,然后该项目将附加到主题行的末尾的传出电子邮件。 (下面省略了修改主题行的部分代码)。

在此 Outlook 会话中:

Public subString As String

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

SubjectAdd.Show
[CODE OMITTED,  but the gist of it is item.subject = item.subject & strstring]

End Sub

在主题内添加用户表单:

Private Sub Append_Click()

Dim i As Long
Dim lngCount As Long

  lngCount = 0
  For i = 0 To MatterList.ListCount - 1
    If MatterList.Selected(i) = True Then
      lngCount = lngCount + 1
      If lngCount = 1 Then
        StrPicks = MatterList.List(i)
      Else
        StrPicks = StrPicks & " " & MatterList.List(i)
      End If
    End If
  Next i

subString = StrPicks
Me.Hide

lbl_Exit:
  Exit Sub

End Sub

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    Public 变量应该可以工作

    作为替代使用Tag 对象的Tag 属性

    Append_Click() 中,在Me.Hide 之前添加最后一行

    Me.Tag = StrPicks
    

    然后在Application_ItemSend(),在任何之前

    Unload SubjectAdd
    

    放置以下

    subject = item.subject & SubjectAdd.Tag
    

    【讨论】:

      猜你喜欢
      • 2021-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-21
      • 1970-01-01
      相关资源
      最近更新 更多