ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   GetAddress (https://www.excelbanter.com/excel-programming/377549-getaddress.html)

ACM Home

GetAddress
 
I'm looking for a way to have excel open outlook address book and have
the user select a contact.
I have an example of this in word that works perfect, however I don't
think that Excel supports this method. I have also seen some info that
is it a bug.
Can someone please explain how to get this to work.

Thanks in advance


Chip Pearson

GetAddress
 
If the VBA code in Word accesses the Outlook object model, those same
routines should work without change in Excel's VBA. Post the code that you
are having problems with.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"ACM Home" wrote in message
oups.com...
I'm looking for a way to have excel open outlook address book and have
the user select a contact.
I have an example of this in word that works perfect, however I don't
think that Excel supports this method. I have also seen some info that
is it a bug.
Can someone please explain how to get this to work.

Thanks in advance




ACM Home

GetAddress
 
I got this code from a word doc that was a lesson on how to get contact
data form outlook/address book. Any help you be great

Option Explicit

Public Sub ClearDocProps()
'Written by Helen Feddema 7-12-98
'Last modified 7-26-98

On Error GoTo ClearDocPropsError

Dim prps As Object

Set prps = ActiveDocument.AttachedTemplate.CustomDocumentProp erties
prps.Item("ToName").Value = ""
prps.Item("ToCompany").Value = ""
prps.Item("ToPhone").Value = ""
prps.Item("ToFax").Value = ""
prps.Item("DateCreated").Value = ""
prps.Item("ToAddress").Value = ""

ClearDocPropsExit:
Exit Sub

ClearDocPropsError:
MsgBox "Error No.: " & Error.Number & "; Description: " &
Error.Description
Resume ClearDocPropsExit

End Sub

Public Function ListCustomProps()

Dim prps As Object
Dim prp As Object

Set prps = ActiveDocument.CustomDocumentProperties

For Each prp In prps
Debug.Print prp.Name
Next prp

End Function

Public Sub AutoNew()
'Written by Helen Feddema 7-12-98
'Last modified 7-26-98

On Error GoTo AutoNewError

Dim strToAddress As String
Dim strToName As String
Dim strToCompany As String
Dim strToPhone As String
Dim strToFax As String
Dim prps As Object

'Pop up address book to allow user to select a contact
strToName = Application.GetAddress(Name:="", _
AddressProperties:="FullName", UseAutoText:=True)
Debug.Print "Name: " & strToName
strToCompany = Application.GetAddress(Name:=strToName, _
AddressProperties:="CompanyName", UseAutoText:=True, _
displayselectdialog:=0)
Debug.Print "Company: " & strToCompany
strToPhone = Application.GetAddress(Name:=strToName, _
AddressProperties:="Phone", UseAutoText:=True, _
displayselectdialog:=0)
Debug.Print "Phone: " & strToPhone
strToFax = Application.GetAddress(Name:=strToName, _
AddressProperties:="Fax", UseAutoText:=True, _
displayselectdialog:=0)
Debug.Print "Fax: " & strToFax
strToAddress = Application.GetAddress(Name:=strToName, _
AddressProperties:="Address", UseAutoText:=True, _
displayselectdialog:=0)
Debug.Print "Address: " & strToAddress

'Assign address entry fields to doc properties
Set prps = ActiveDocument.CustomDocumentProperties
prps.Item("ToName").Value = strToName
prps.Item("ToCompany").Value = strToCompany
prps.Item("ToPhone").Value = strToPhone
prps.Item("ToFax").Value = strToFax
prps.Item("ToAddress").Value = strToAddress

'Assign today's date to property
prps.Item("DateCreated").Value = Format(Now(), "Short Date")

'Update fields in document
Selection.WholeStory
Selection.Fields.Update
Selection.HomeKey Unit:=wdStory

AutoNewExit:
Exit Sub

AutoNewError:
MsgBox "Error No.: " & Error.Number & "; Description: " &
Error.Description
Resume AutoNewExit

End Sub

On Nov 17, 11:12 am, "Chip Pearson" wrote:
If the VBA code in Word accesses the Outlook object model, those same
routines should work without change in Excel's VBA. Post the code that you
are having problems with.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLCwww.cpearson.com
(email address is on the web site)

"ACM Home" wrote in ooglegroups.com...



I'm looking for a way to have excel open outlook address book and have
the user select a contact.
I have an example of this in word that works perfect, however I don't
think that Excel supports this method. I have also seen some info that
is it a bug.
Can someone please explain how to get this to work.


Thanks in advance- Hide quoted text -- Show quoted text -




All times are GMT +1. The time now is 03:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com