您好我希望能够在 Excel 中访问 Outlook GAL。我正在使用 Office 2010(Excel 2010 和 Outlook 2010)。我正在寻找的是能够按下一个按钮,然后 GAL 将显示一个对话框,然后我可以在其中搜索我需要的收件人详细信息,然后插入到一个单元格中。在互联网上搜索后,我发现了适用于 Microsoft Word 的代码,但在 excel 中使用时会出现错误。
这是这里提供的代码http://www.vbaexpress.com/forum/archive/index.php/t-24694.html
Public Sub InsertAddressFromOutlook()
Dim strCode As String, strAddress As String
Dim iDoubleCR As Integer
'Set up the formatting codes in strCode
strCode = "<PR_DISPLAY_NAME>" & vbCr & _
"<PR_POSTAL_ADDRESS>" & vbCr & _
"<PR_OFFICE_TELEPHONE_NUMBER>" & vbCr
'Display the 'Select Name' dialog, which lets the user choose
'a name from their Outlook address book
strAddress = Application.GetAddress(AddressProperties:=strCode, _
UseAutoText:=False, DisplaySelectDialog:=1, _
RecentAddressesChoice:=True, UpdateRecentAddresses:=True)
'If user cancelled out of 'Select Name' dialog, quit
If strAddress = "" Then Exit Sub
'Eliminate blank paragraphs by looking for two carriage returns in a row
iDoubleCR = InStr(strAddress, vbCr & vbCr)
Do While iDoubleCR <> 0
strAddress = Left(strAddress, iDoubleCR - 1) & _
Mid(strAddress, iDoubleCR + 1)
iDoubleCR = InStr(strAddress, vbCr & vbCr)
Loop
'Strip off final paragraph mark
strAddress = Left(strAddress, Len(strAddress) - 1)
'Insert the modified address at the current insertion point
Selection.Range.Text = strAddress
End Sub
因此,当运行此宏时,返回错误是运行时错误 438,Object 不支持此属性或方法
,并且突出显示的错误代码块是
strAddress = Application.GetAddress(AddressProperties:=strCode, _
UseAutoText:=False, DisplaySelectDialog:=1, _
RecentAddressesChoice:=True, UpdateRecentAddresses:=True)
任何人都可以提供代码解决方案吗?提前致谢