无法将值从用户表单传递到模块 [英] Unable to Pass Value from Userform to Module

查看:75
本文介绍了无法将值从用户表单传递到模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有,我试图将一个或多个选定项目的值从用户表单传递到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

这篇关于无法将值从用户表单传递到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆