使用VBA从Excel获取Outlook联系人 [英] Getting an Outlook contact from Excel with VBA
本文介绍了使用VBA从Excel获取Outlook联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个MS Office 2015(即将成为2016年)Excel工作表,其中包含名称,例如John Smith。 我还将名称定义为Outlook中的联系人。 我希望能够在Excel中打开Outlook联系人,以便实时查看数据,尤其是
Notes。 我可以获得建议的VBA代码吗?非常感谢您的帮助。
解决方案
运行以下代码时:
Dim oApp As Object
Dim oNspc As Object
Dim oItm As Object
Set oApp = CreateObject(" Outlook.Application")
Set oNspc = oApp.GetNamespace(" MAPI" )
每个oItm在oNspc.GetDefaultFolder(10).Items
如果oItm.FullName = Sheets(1).Range(" A1")那么
MsgBox oItm.FullName& vbCr& oItm.CompanyName& vbCr& oItm.JobTitle& vbCr& oItm.BusinessAddress
退出
结束如果
下一个oItm
结果是:
I have an MS Office 2015 (soon to be 2016) Excel worksheet with names in, eg John Smith. I also have the name defined as a Contact in Outlook. I wish to be able to open that Outlook Contact while in Excel so as to view the data, especially Notes, in real time. Can I get suggested VBA code to do this, please? Thanks much for any help.
解决方案
When the following code is run:
Dim oApp As Object Dim oNspc As Object Dim oItm As Object Set oApp = CreateObject("Outlook.Application") Set oNspc = oApp.GetNamespace("MAPI") For Each oItm In oNspc.GetDefaultFolder(10).Items If oItm.FullName = Sheets(1).Range("A1") Then MsgBox oItm.FullName & vbCr & oItm.CompanyName & vbCr & oItm.JobTitle & vbCr & oItm.BusinessAddress Exit For End If Next oItmthe result is:
这篇关于使用VBA从Excel获取Outlook联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文