G
Guest
Trying to import data from a custom form, I found an article and tried to
adapt the code to the custom mail message I created for my organisation, but
cannot have it to work.
I cannot write code, so I cannot understand where is the problem.
I am working with accessxp.
Here is the adapted code:
Dim PublicFolder As MAPIFolder
Dim OldTaskItems As Items
Dim itm As Outlook.MailItem
Dim AppPath As String
Sub ImportItems()
Set PublicFolder = ol.GetNamespace("MAPI").Folders("Cassetta Postale - Sara
Messina").Folders("Assunzioni")
Set OldTaskItems = PublicFolder.Items.Restrict("[Subject] > ''")
Dim nmritens As Integer
nmritens = OldTaskItems.Count
For Each itm In OldTaskItems
If nmritens > 1 Then
Set appAccess = CreateObject("Access.Application")
strAccessPath = appAccess.SysCmd(9)
strDBName = "C:\Documents and Settings\SaraMessina\Desktop" &
"importoutlook.mdb" 'strAccessPath & "importoutlook.mdb"
Set dbe = CreateObject("DAO.DBEngine.36")
Set wks = dbe.Workspaces(0)
Set dbs = wks.OpenDatabase(strDBName)
Set rst = dbs.OpenRecordset("tblHdrs")
rst.AddNew
rst.Da = itm.UserProperties("Da")
rst.Inviato = itm.UserProperties("Inviato")
rst.Assunzione = itm.UserProperties("Assunzione")
rst.cessaz = itm.UserProperties("Cessaz")
rst.DFine = itm.UserProperties("DFine")
rst.DInizio = itm.UserProperties("DInizio")
rst.Modifica = itm.UserProperties("Modifica")
rst.Motivazione = itm.UserProperties("Motivazione")
rst.Nuovo = itm.UserProperties("Nuovo")
rst.Ore = itm.UserProperties("Ore")
rst.RepRichied = itm.UserProperties("RepRichied")
rst.Sostituito = itm.UserProperties("Sostituito")
rst.Sostituto = itm.UserProperties("Sostituto")
rst.Update
rst.Close
dbs.Close
End If
Next
End Sub
When it gets to the line: "Set appAccess =
CreateObject("Access.Application")" it stops executing the module and it
gives me a message saying: Run-time error 429 - the activeX control cannot
create the object.
Is there a way i can get it to work??
Thank you
Sara
adapt the code to the custom mail message I created for my organisation, but
cannot have it to work.
I cannot write code, so I cannot understand where is the problem.
I am working with accessxp.
Here is the adapted code:
Dim PublicFolder As MAPIFolder
Dim OldTaskItems As Items
Dim itm As Outlook.MailItem
Dim AppPath As String
Sub ImportItems()
Set PublicFolder = ol.GetNamespace("MAPI").Folders("Cassetta Postale - Sara
Messina").Folders("Assunzioni")
Set OldTaskItems = PublicFolder.Items.Restrict("[Subject] > ''")
Dim nmritens As Integer
nmritens = OldTaskItems.Count
For Each itm In OldTaskItems
If nmritens > 1 Then
Set appAccess = CreateObject("Access.Application")
strAccessPath = appAccess.SysCmd(9)
strDBName = "C:\Documents and Settings\SaraMessina\Desktop" &
"importoutlook.mdb" 'strAccessPath & "importoutlook.mdb"
Set dbe = CreateObject("DAO.DBEngine.36")
Set wks = dbe.Workspaces(0)
Set dbs = wks.OpenDatabase(strDBName)
Set rst = dbs.OpenRecordset("tblHdrs")
rst.AddNew
rst.Da = itm.UserProperties("Da")
rst.Inviato = itm.UserProperties("Inviato")
rst.Assunzione = itm.UserProperties("Assunzione")
rst.cessaz = itm.UserProperties("Cessaz")
rst.DFine = itm.UserProperties("DFine")
rst.DInizio = itm.UserProperties("DInizio")
rst.Modifica = itm.UserProperties("Modifica")
rst.Motivazione = itm.UserProperties("Motivazione")
rst.Nuovo = itm.UserProperties("Nuovo")
rst.Ore = itm.UserProperties("Ore")
rst.RepRichied = itm.UserProperties("RepRichied")
rst.Sostituito = itm.UserProperties("Sostituito")
rst.Sostituto = itm.UserProperties("Sostituto")
rst.Update
rst.Close
dbs.Close
End If
Next
End Sub
When it gets to the line: "Set appAccess =
CreateObject("Access.Application")" it stops executing the module and it
gives me a message saying: Run-time error 429 - the activeX control cannot
create the object.
Is there a way i can get it to work??
Thank you
Sara