无法将值从用户表单传递到模块
所有,我试图将一个或多个选定项目的值从用户表单传递到ThisOutlookSession中,但是无法传递字符串.感谢您对我可能会出错的地方的想法.
All, I'm trying to pass the value of a selected item (or items) from a userform into ThisOutlookSession, but cannot pass the string. Grateful for thoughts on where I might be going wrong.
这个想法是用一个来自txt文件的引用列表填充一个列表框(效果很好),用户将从列表框中选择一个项目,然后将该项目追加到主题行的末尾外发电子邮件. (下面省略了修改主题行的代码部分.)
The idea is to populate a listbox with a list of references from a txt file (which works fine), the user will select an item from a list box, and that item will then be appended to the end of the subject line of an outgoing email. (The part of the code which amends the subject line is omitted from the below).
在ThisOutlookSession中:
Within ThisOutlookSession:
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
在SubjectAdd用户表单内:
Within SubjectAdd userform:
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
Public
变量应该起作用
作为替代选择,使用UserForm
对象的Tag
属性
As an alternative use Tag
property of UserForm
object
在Append_Click()
中,在Me.Hide
Me.Tag = StrPicks
然后在Application_ItemSend()
中,先于
Unload SubjectAdd
放置以下
subject = item.subject & SubjectAdd.Tag