importing in access outlook custom forms

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
 
D

David C. Holley

See my reply in newsgroup: microsoft.public.outlook.program_vba
I sent it there because that forum is a bit more appropriate for the
problem.
 
D

David C. Holley

It appears that you've adapted code that was originally designed to run
from within OUTLOOK as opposed to code that was designed to run from
within ACCESS. There is a difference. Please post the ORIGINAL code. I'd
like to start there.
 
G

Guest

Hopefully David has a solution for you. I just want to recommend learning
VBA if this is something you may be doing on a regular basis. It's really
not that hard and there are many, many excellent books that use a tutorial
approach that may help you. The "Access 2000 Visual Basic for Applications
Fundamentals" was a great one for me (and I'm sure there's an updated
edition). Once you get the hang of VBA, you'll be hooked!

Randall Arnold
 
G

Guest

Hi David, thank you for your help.
the code was supposed to be for Access, here is the link to the article
where I copied it from. I tried to follow it as best as I could.

http://www.outlookexchange.com/articles/ricardosilva/out2acc.asp

thank you again
Sara

David C. Holley said:
It appears that you've adapted code that was originally designed to run
from within OUTLOOK as opposed to code that was designed to run from
within ACCESS. There is a difference. Please post the ORIGINAL code. I'd
like to start there.
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
 
G

Guest

You are right! I am trying to learn and am actually looking for a course to
learn VBA, because I have enough of having this kind of problems!
Sara

Randall Arnold said:
Hopefully David has a solution for you. I just want to recommend learning
VBA if this is something you may be doing on a regular basis. It's really
not that hard and there are many, many excellent books that use a tutorial
approach that may help you. The "Access 2000 Visual Basic for Applications
Fundamentals" was a great one for me (and I'm sure there's an updated
edition). Once you get the hang of VBA, you'll be hooked!

Randall Arnold

sara said:
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
 
G

Guest

Good for you! I wish you success.

I just got another book that I HIGHLY recommend: "Access Cookbook" from
O'Reilly (Ken Getz, et al). This is a great book for people who need tips
and techniques for complex needs. It goes into significant detail when
explaining each bit of code.

Randall Arnold

sara said:
You are right! I am trying to learn and am actually looking for a course to
learn VBA, because I have enough of having this kind of problems!
Sara

Randall Arnold said:
Hopefully David has a solution for you. I just want to recommend learning
VBA if this is something you may be doing on a regular basis. It's really
not that hard and there are many, many excellent books that use a tutorial
approach that may help you. The "Access 2000 Visual Basic for Applications
Fundamentals" was a great one for me (and I'm sure there's an updated
edition). Once you get the hang of VBA, you'll be hooked!

Randall Arnold

sara said:
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
 
G

Guest

David means that while the code was intended to be used for Access, it
appears to have been designed to execute from within Outlook. The difference
manifests in top-level object references. Each Office constituent (Access,
Outlook, Word, et al) uses the same VBA *syntax* but the top level object
(Application) is unique and so are other aspects related to that
Application's distinct functions.

If I write code that runs completely within Access, I don't need to
reference the Access Application object; The VBA interpreter understands that
if I omit this then I must be referring to the Application in which I'm
running code, ie, Access. HOWEVER-- if I want to refer to other
Applications, I need to include a reference to them in the Tools/References
list and also declare them specifically. The code sample below omits the
Outlook Application references so it appears to have been designed to run
inside of Outlook, even if the code is meant to manipulate Access. Note that
in one line an instance of Access is created (Set appAccess =
CreateObject("Access.Application")); this wouldn't usually be done from
within Access.

Randall Arnold

sara said:
Hi David, thank you for your help.
the code was supposed to be for Access, here is the link to the article
where I copied it from. I tried to follow it as best as I could.

http://www.outlookexchange.com/articles/ricardosilva/out2acc.asp

thank you again
Sara

David C. Holley said:
It appears that you've adapted code that was originally designed to run
from within OUTLOOK as opposed to code that was designed to run from
within ACCESS. There is a difference. Please post the ORIGINAL code. I'd
like to start there.
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
 
D

David C. Holley

Check you're local Community Colleges for a programming class(es) on one
or more of the Office products or Office as a whole. Be certain to
contact the instructor and ask about VBA. Otherwise, you may want to try
an Intro to Programming class (to get your feet wet) followed by a VB
class. The VB class will have much more than you probalby need but it
should set up to deal with VBA. (I'll tackle the other problem shortly)
You are right! I am trying to learn and am actually looking for a course to
learn VBA, because I have enough of having this kind of problems!
Sara

:

Hopefully David has a solution for you. I just want to recommend learning
VBA if this is something you may be doing on a regular basis. It's really
not that hard and there are many, many excellent books that use a tutorial
approach that may help you. The "Access 2000 Visual Basic for Applications
Fundamentals" was a great one for me (and I'm sure there's an updated
edition). Once you get the hang of VBA, you'll be hooked!

Randall Arnold

:

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
 
D

David C. Holley

To double check, you're trying to take TaskItems from Outlook and drop
them into an Access database?
Hi David, thank you for your help.
the code was supposed to be for Access, here is the link to the article
where I copied it from. I tried to follow it as best as I could.

http://www.outlookexchange.com/articles/ricardosilva/out2acc.asp

thank you again
Sara

:

It appears that you've adapted code that was originally designed to run
from within OUTLOOK as opposed to code that was designed to run from
within ACCESS. There is a difference. Please post the ORIGINAL code. I'd
like to start there.
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
 
G

Guest

No I work with a Mail Item, that's why I changed in my code from
outlook.TaskItem to Outlook.MailItem

But I kind of solved the problem and changed the line to:

Set appAccess = Application

and it works, but now it gets stuck in:

rst.DInizio = itm.UserProperties("DInizio")

where it tells me run time error 438 method or property not supported by the
object
and I find this quite strange because the line before this refers to the
same kind of item (date/time ) and there it works.

Thank you again
David C. Holley said:
To double check, you're trying to take TaskItems from Outlook and drop
them into an Access database?
Hi David, thank you for your help.
the code was supposed to be for Access, here is the link to the article
where I copied it from. I tried to follow it as best as I could.

http://www.outlookexchange.com/articles/ricardosilva/out2acc.asp

thank you again
Sara

:

It appears that you've adapted code that was originally designed to run
from within OUTLOOK as opposed to code that was designed to run from
within ACCESS. There is a difference. Please post the ORIGINAL code. I'd
like to start there.

sara wrote:

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
 
D

David C. Holley

The UserProperties are case sensitive. "DInizio" is not the same as
"dinizio". Check the names of the user-definded fields in Outlook or
when the code fails select DEBUG. This will display the code and the
immediate window. In the immediate window type

Debug.Print itm.UserProperties.Count

This will give you the NUMBER of UserProperties for the item. From there
type

Debug.Print itm.UserProperties(x)

where x is any number from 1 to the number of userProperties. This will
allow you to snoop around to see the actual names of the userproperties.
No I work with a Mail Item, that's why I changed in my code from
outlook.TaskItem to Outlook.MailItem

But I kind of solved the problem and changed the line to:

Set appAccess = Application

and it works, but now it gets stuck in:

rst.DInizio = itm.UserProperties("DInizio")

where it tells me run time error 438 method or property not supported by the
object
and I find this quite strange because the line before this refers to the
same kind of item (date/time ) and there it works.

Thank you again
:

To double check, you're trying to take TaskItems from Outlook and drop
them into an Access database?
Hi David, thank you for your help.
the code was supposed to be for Access, here is the link to the article
where I copied it from. I tried to follow it as best as I could.

http://www.outlookexchange.com/articles/ricardosilva/out2acc.asp

thank you again
Sara

:



It appears that you've adapted code that was originally designed to run

from within OUTLOOK as opposed to code that was designed to run from

within ACCESS. There is a difference. Please post the ORIGINAL code. I'd
like to start there.

sara wrote:


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top