export to access

export to access

Post by PaulCampbe » Sat, 05 Jul 2003 22:08:58


i,

I am building an application for a network. Part of the
application requires a public contacts folder in outlook
to be searched from an ASP page. I found the easiest way
to do this was to export the contacts to an Access
database, and have the ASP page search that. The problem
this caused, was when new contacts were added outlook,
they have to be exported to Access.

I built a custom form in Outlook, which contains
an "Export to Access" button. When the button is pressed,
the contact adds itslef to Access table as a new record.

Here is the code from the outlook form:

Sub cmdExport_Click

Dim objWord
Dim strDocsDir
Dim strDBName
Dim dao
Dim dbs
Dim rst


Set objWord = Item.Application.CreateObject
("Word.Application")
strDocsDir = objWord.System.PrivateProfileString
("", "HKEY_CURRENT_USER\Software\Microsoft\Windows\Current
Version\Explorer\Shell Folders", "Personal")
strDBName = "\\PCL01
\c$\InetPub\wwwroot\quotebuilder\personal.mdb"
MsgBox "DBName: " & strDBName
objWord.Quit
Set dao = Application.CreateObject("DAO.DBEngine.35")
Set dao = DAO.Workspaces(0)
Set dbs = dao.OpenDatabase(strDBName)
Set rst = dbs.OpenRecordset("Contacts")
rst.AddNew
If Item.Title <> "" Then rst.Title = Item.Title
If Item.FirstName <> "" Then rst.FirstName =
Item.FirstName
If Item.MiddleName <> "" Then rst.MiddleName =
Item.MiddleName
If Item.LastName <> "" Then rst.LastName = Item.LastName
If Item.Suffix <> "" Then rst.Suffix = Item.Suffix
If Item.CompanyName <> "" Then rst.Company =
Item.CompanyName
If Item.JobTitle <> "" Then rst.JobTitle = Item.JobTitle
If Item.BusinessAddressStreet <> "" Then
rst.BusinessStreet = Item.BusinessAddressStreet
If Item.BusinessAddressCity <> "" Then rst.BusinessCity =
Item.BusinessAddressCity
If Item.BusinessAddressState <> "" Then rst.BusinessState
= Item.BusinessAddressState
If Item.BusinessAddressPostalCode <> "" Then
rst.BusinessPostalCode = Item.BusinessAddressPostalCode
If Item.BusinessAddressCountry <> "" Then
rst.BusinessCountry = Item.BusinessAddressCountry
If Item.HomeAddressStreet <> "" Then rst.HomeStreet =
Item.HomeAddressStreet
If Item.HomeAddressCity <> "" Then rst.HomeCity =
Item.HomeAddressCity
If Item.HomeAddressState <> "" Then rst.HomeState =
Item.HomeAddressState
If Item.HomeAddressPostalCode <> "" Then
rst.HomePostalCode = Item.HomeAddressPostalCode
If Item.HomeAddressCountry <> "" Then rst.HomeCountry =
Item.HomeAddressCountry
If Item.OtherAddressStreet <> "" Then rst.OtherStreet =
Item.OtherAddressStreet
If Item.OtherAddressCity <> "" Then rst.OtherCity =
Item.OtherAddressCity
If Item.OtherAddressState <> "" Then rst.OtherState =
Item.OtherAddressState
If Item.OtherAddressPostalCode <> "" Then
rst.OtherPostalCode = Item.OtherAddressPostalCode
If Item.OtherAddressCountry <> "" Then rst.OtherCountry =
Item.OtherAddressCountry
If Item.BusinessFaxNumber <> "" Then rst.BusinessFax =
Item.BusinessFaxNumber
If Item.BusinessTelephoneNumber <> "" Then
rst.BusinessPhone = Item.BusinessTelephoneNumber
If Item.Business2TelephoneNumber <> "" Then
rst.BusinessPhone2 = Item.Business2TelephoneNumber
If Item.CallbackTelephoneNumber <> "" Then rst.Callback =
Item.CallbackTelephoneNumber
If Item.CarTelephoneNumber <> "" Then rst.CarPhone =
 
 
 

export to access

Post by George Hes » Tue, 08 Jul 2003 07:13:43

id you try it with just;

Set dao = CreateObject("DAO.DBEngine")

You might be able to set the version after doing this or include it as you did below. Not sure about the version part.

--
George Hester
__________________________________
"PaulCampbell" < XXXX@XXXXX.COM > wrote in message news:5b5e01c3422d$6e3c8f50$ XXXX@XXXXX.COM ...