P
PaulCampbell
Hi,
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 =
Item.CarTelephoneNumber
If Item.CompanyMainTelephoneNumber <> "" Then
rst.CompanyMainPhone = Item.CompanyMainTelephoneNumber
If Item.HomeFaxNumber <> "" Then rst.HomeFax =
Item.HomeFaxNumber
If Item.HomeTelephoneNumber <> "" Then rst.HomePhone =
Item.HomeTelephoneNumber
If Item.Home2TelephoneNumber <> "" Then rst.HomePhone2 =
Item.Home2TelephoneNumber
If Item.ISDNNumber <> "" Then rst.ISDN = Item.ISDNNumber
If Item.MobileTelephoneNumber <> "" Then rst.MobilePhone
= Item.MobileTelephoneNumber
If Item.OtherFaxNumber <> "" Then rst.OtherFax =
Item.OtherFaxNumber
If Item.OtherTelephoneNumber <> "" Then rst.OtherPhone =
Item.OtherTelephoneNumber
If Item.PagerNumber <> "" Then rst.Pager =
Item.PagerNumber
If Item.PrimaryTelephoneNumber <> "" Then
rst.PrimaryPhone = Item.PrimaryTelephoneNumber
If Item.RadioTelephoneNumber <> "" Then rst.RadioPhone =
Item.RadioTelephoneNumber
If Item.TTYTDDTelephoneNumber <> "" Then rst.TTYTDDPhone
= Item.TTYTDDTelephoneNumber
If Item.TelexNumber <> "" Then rst.Telex =
Item.TelexNumber
If Item.BillingInformation <> "" Then
rst.BillingInformation = Item.BillingInformation
If Item.Email1Address <> "" Then rst.EmailAddress =
Item.Email1Address
If Item.Email1DisplayName <> "" Then rst.EmailDisplayName
= Item.Email1DisplayName
If Item.Email2Address <> "" Then rst.Email2Address =
Item.Email2Address
If Item.Email2DisplayName <> "" Then
rst.Email2DisplayName = Item.Email2DisplayName
If Item.Email3Address <> "" Then rst.Email3Address =
Item.Email3Address
If Item.Email3DisplayName <> "" Then
rst.Email3DisplayName = Item.Email3DisplayName
If Item.Subject <> "" Then rst.Notes = Item.Subject
If Item.WebPage <> "" Then rst.WebPage = Item.WebPage
If Item.Categories <> "" Then rst.Categories =
Item.Categories
rst.Update
rst.Close
MsgBox Item.FirstName & " " & Item.LastName & "'s data
exported to Contacts"
End Sub
This worked fine on my computer. I then tried the form
out on other computers in the office, and they returned:
"Internal Application Error"
When the debugger was opened, it seems to suggest that
the problem is with the line:
Set dao = Application.CreateObject("DAO.DBEngine.35")
Any suggestions as to what could be causing this would be
greatly appreciated.
Regards,
Paul
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 =
Item.CarTelephoneNumber
If Item.CompanyMainTelephoneNumber <> "" Then
rst.CompanyMainPhone = Item.CompanyMainTelephoneNumber
If Item.HomeFaxNumber <> "" Then rst.HomeFax =
Item.HomeFaxNumber
If Item.HomeTelephoneNumber <> "" Then rst.HomePhone =
Item.HomeTelephoneNumber
If Item.Home2TelephoneNumber <> "" Then rst.HomePhone2 =
Item.Home2TelephoneNumber
If Item.ISDNNumber <> "" Then rst.ISDN = Item.ISDNNumber
If Item.MobileTelephoneNumber <> "" Then rst.MobilePhone
= Item.MobileTelephoneNumber
If Item.OtherFaxNumber <> "" Then rst.OtherFax =
Item.OtherFaxNumber
If Item.OtherTelephoneNumber <> "" Then rst.OtherPhone =
Item.OtherTelephoneNumber
If Item.PagerNumber <> "" Then rst.Pager =
Item.PagerNumber
If Item.PrimaryTelephoneNumber <> "" Then
rst.PrimaryPhone = Item.PrimaryTelephoneNumber
If Item.RadioTelephoneNumber <> "" Then rst.RadioPhone =
Item.RadioTelephoneNumber
If Item.TTYTDDTelephoneNumber <> "" Then rst.TTYTDDPhone
= Item.TTYTDDTelephoneNumber
If Item.TelexNumber <> "" Then rst.Telex =
Item.TelexNumber
If Item.BillingInformation <> "" Then
rst.BillingInformation = Item.BillingInformation
If Item.Email1Address <> "" Then rst.EmailAddress =
Item.Email1Address
If Item.Email1DisplayName <> "" Then rst.EmailDisplayName
= Item.Email1DisplayName
If Item.Email2Address <> "" Then rst.Email2Address =
Item.Email2Address
If Item.Email2DisplayName <> "" Then
rst.Email2DisplayName = Item.Email2DisplayName
If Item.Email3Address <> "" Then rst.Email3Address =
Item.Email3Address
If Item.Email3DisplayName <> "" Then
rst.Email3DisplayName = Item.Email3DisplayName
If Item.Subject <> "" Then rst.Notes = Item.Subject
If Item.WebPage <> "" Then rst.WebPage = Item.WebPage
If Item.Categories <> "" Then rst.Categories =
Item.Categories
rst.Update
rst.Close
MsgBox Item.FirstName & " " & Item.LastName & "'s data
exported to Contacts"
End Sub
This worked fine on my computer. I then tried the form
out on other computers in the office, and they returned:
"Internal Application Error"
When the debugger was opened, it seems to suggest that
the problem is with the line:
Set dao = Application.CreateObject("DAO.DBEngine.35")
Any suggestions as to what could be causing this would be
greatly appreciated.
Regards,
Paul