本文介绍了VBA / userforms的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好,我遇到自定义用户表单的问题。我正在尝试为我工作的公司创建一个电子邮件模板。用户Outlook联系人列表将插入组合框中,当用户选择联系人时,我希望程序自动将联系人地址和信息插入Word文档。我已初始化用户表单,但在找到获取地址信息的方法时遇到问题。插入。对于这样一个新问题我很抱歉,我对VBA很新。如果这不是发布此特定问题的正确位置,请将其指向其他地方。提前谢谢! 这是我到目前为止的代码... 私人子用户表格_初始化()Hello all, I am having a problem with a custom user form. I am trying to create an email template for the company I work for. The users Outlook contact list will be inserted into a combobox and when the user chooses a contact, I would like to have the program automatically insert the contacts address and information into the Word document. I have the user form initialized, but am having problems finding a way to get the address info. inserted. Sorry for such a newbish question, I am very new to VBA. If this isn't the right place to be posting this particular question, please direct me elsewhere. thanks in advance!This is the code I have so far...Private Sub UserForm_Initialize() Dim oApp As Outlook.Application Dim oNspc As NameSpace Dim oItm作为ContactItem Dim x作为整数如果不是DisplayStatusBar那么 结束如果是StatusBar =" Please Wait ..." x = 0 设置oApp = CreateObject(" Outlook.Application")设置oNspc = oApp.GetNamespace ("MAPI")对于每个oItm inOnspc.GetDefaultFolder _ (olFolderContacts)。项目与Me.contactlist .AddItem(oItm.FullName) .Column(1,x)= oItm.BusinessAddress .Column(2,x)= oItm.BusinessAddressCity .Column(3,x)= oItm.BusinessAddressState .Column(4, x)= oItm.BusinessAddressPostalCode .Column (5,x)= oItm.Email1Address 结束与 x = x + 1 下一个oItm StatusBar ="" 设置oItm = Nothing 设置oNspc = Nothing 设置oApp = Nothing End SubDim oApp As Outlook.Application Dim oNspc As NameSpace Dim oItm As ContactItem Dim x As Integer If Not DisplayStatusBar Then DisplayStatusBar = True End If StatusBar = "Please Wait..." x = 0 Set oApp = CreateObject("Outlook.Application") Set oNspc = oApp.GetNamespace("MAPI") For Each oItm In oNspc.GetDefaultFolder _ (olFolderContacts).Items With Me.contactlist .AddItem (oItm.FullName) .Column(1, x) = oItm.BusinessAddress .Column(2, x) = oItm.BusinessAddressCity .Column(3, x) = oItm.BusinessAddressState .Column(4, x) = oItm.BusinessAddressPostalCode .Column(5, x) = oItm.Email1Address End With x = x + 1 Next oItm StatusBar = "" Set oItm = Nothing Set oNspc = Nothing Set oApp = Nothing End Sub 推荐答案这是VB.Net论坛。我在下面的论坛中包含了粘性帖子,其中包含指向您需要发布VBA问题的正确论坛的链接: 对于VBA,Office(VSTO),宏和VBScript问题This is the VB.Net forum. I've included the sticky thread from this forum below which contains a link to the correct forum where you need to post VBA questions:For VBA, Office (VSTO), Macros and VBScript Questions 这篇关于VBA / userforms的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 22:50