![]() |
| If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|||||||
| Tags: access, calendar, export, lousy, plus, problems, programatic, programmer |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I'm using this code to export a calendar to access and it works, but
there's some weird 'errors'. A) not every calendar item was 'grabbed.' 2 fridays ago everything was taken, but last friday several things were not added to the database. B) There seems to be no rhyme or reason to the order of what it grabs. (maybe some other field i'm not looking at). Could I, (should I?) sort the record set before grabbing? Here's my limitations which I would love to know how to overcome. I know these things suck and good programmers will chastize me. But we have a fast computer and low amounts of data so I can be lazy (but i'd rather find a more elegant solution). 1) Since there seems to be no order I'm stuck with just guessing where to stop grabbing, and since there are 20,000 items in the calendar going back to the late 90s, i can't grab them all. (i can, but it takes alot longer than grabbing 900). 2) I delete everything at the start so I can get the 'freshest' data. (someone might change a 2 week old calendar item). 3) A link to outlook through access doesn't grab the start time of the calendar item (why it doesn't is beyond my guess, anyone who makes a calendar program should expect users would want to know start time) Here's the code, it takes parts from other people on the net so i don't claim 100% credit: Sub pushcalendartoaccess_beta() Dim fld As Outlook.MAPIFolder Dim appAccess As Access.Application Dim objItems As Outlook.Items Dim lngcount As Long Dim debug1 As Date Dim debug2 As String Dim rst As DAO.Recordset Set rst = CurrentDb.OpenRecordset("tblCalendar") Set fld = GetFolder("Public Folders/Favorites/Conyers Interviews") If fld Is Nothing Then GoTo ErrorHandlerExit End If If fld.DefaultItemType olAppointmentItem Then MsgBox "Folder is not a calendar folder" GoTo ErrorHandlerExit End If Debug.Print fld.FolderPath lngcount = fld.Items.Count Debug.Print lngcount If lngcount = 0 Then MsgBox "No appointments to export" GoTo ErrorHandlerExit Else Debug.Print lngcount & " appointments to export" End If 'this code deletes the database every time, so there's no duplicates If rst.BOF And rst.EOF Then Else rst.MoveFirst Do Until rst.EOF rst.Delete rst.MoveNext Loop End If Set objItems = fld.Items Dim i For i = 1 To 170 ' debug1 = fld.Items(i).Start ' debug2 = fld.Items(i).Subject ' Debug.Print debug1 ' Debug.Print debug2 rst.AddNew rst!Subject = fld.Items(i).Subject rst!Date = fld.Items(i).Start rst.Update Next Set fld = GetFolder("Public Folders/Favorites/Interviews") Set objItems = fld.Items For i = 2 To 890 ' debug1 = fld.Items(i).Start ' debug2 = fld.Items(i).Subject ' Debug.Print debug1 ' Debug.Print debug2 rst.AddNew rst!Subject = fld.Items(i).Subject rst!Date = fld.Items(i).Start rst.Update Next rst.Close 'error handlers End Sub |
| Ads |
|
#2
|
|||
|
|||
|
1) There's no order unless you set one by calling the MAPIFolder.Items.Sort method.
2) Consider filtering for a date range. See http://www.outlookcode.com/d/finddate.htm 3) The linked table method has major limitations, including the inability to show even all the reasonably important fields. FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/comm....program_v ba -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "krislikesmath" wrote in message oups.com... I'm using this code to export a calendar to access and it works, but there's some weird 'errors'. A) not every calendar item was 'grabbed.' 2 fridays ago everything was taken, but last friday several things were not added to the database. B) There seems to be no rhyme or reason to the order of what it grabs. (maybe some other field i'm not looking at). Could I, (should I?) sort the record set before grabbing? Here's my limitations which I would love to know how to overcome. I know these things suck and good programmers will chastize me. But we have a fast computer and low amounts of data so I can be lazy (but i'd rather find a more elegant solution). 1) Since there seems to be no order I'm stuck with just guessing where to stop grabbing, and since there are 20,000 items in the calendar going back to the late 90s, i can't grab them all. (i can, but it takes alot longer than grabbing 900). 2) I delete everything at the start so I can get the 'freshest' data. (someone might change a 2 week old calendar item). 3) A link to outlook through access doesn't grab the start time of the calendar item (why it doesn't is beyond my guess, anyone who makes a calendar program should expect users would want to know start time) Here's the code, it takes parts from other people on the net so i don't claim 100% credit: Sub pushcalendartoaccess_beta() Dim fld As Outlook.MAPIFolder Dim appAccess As Access.Application Dim objItems As Outlook.Items Dim lngcount As Long Dim debug1 As Date Dim debug2 As String Dim rst As DAO.Recordset Set rst = CurrentDb.OpenRecordset("tblCalendar") Set fld = GetFolder("Public Folders/Favorites/Conyers Interviews") If fld Is Nothing Then GoTo ErrorHandlerExit End If If fld.DefaultItemType olAppointmentItem Then MsgBox "Folder is not a calendar folder" GoTo ErrorHandlerExit End If Debug.Print fld.FolderPath lngcount = fld.Items.Count Debug.Print lngcount If lngcount = 0 Then MsgBox "No appointments to export" GoTo ErrorHandlerExit Else Debug.Print lngcount & " appointments to export" End If 'this code deletes the database every time, so there's no duplicates If rst.BOF And rst.EOF Then Else rst.MoveFirst Do Until rst.EOF rst.Delete rst.MoveNext Loop End If Set objItems = fld.Items Dim i For i = 1 To 170 ' debug1 = fld.Items(i).Start ' debug2 = fld.Items(i).Subject ' Debug.Print debug1 ' Debug.Print debug2 rst.AddNew rst!Subject = fld.Items(i).Subject rst!Date = fld.Items(i).Start rst.Update Next Set fld = GetFolder("Public Folders/Favorites/Interviews") Set objItems = fld.Items For i = 2 To 890 ' debug1 = fld.Items(i).Start ' debug2 = fld.Items(i).Subject ' Debug.Print debug1 ' Debug.Print debug2 rst.AddNew rst!Subject = fld.Items(i).Subject rst!Date = fld.Items(i).Start rst.Update Next rst.Close 'error handlers End Sub |
|
#3
|
|||
|
|||
|
Oh, thanks, I didn't know of the sort methods. Nor how to filter. I
will better assign my posts next time. Thanks for posting code, I don't think i used any of yours in the above code (maybe getfolder() method was yours) but looking at your code snipits allowed me to better understand what was going on and how to change things to suit my needs. On Mar 13, 1:06 pm, "Sue Mosher [MVP-Outlook]" wrote: 1) There's no order unless you set one by calling the MAPIFolder.Items.Sort method. 2) Consider filtering for a date range. Seehttp://www.outlookcode.com/d/finddate.htm 3) The linked table method has major limitations, including the inability to show even all the reasonably important fields. FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, athttp://www.microsoft.com/office/community/en-us/default.mspx?dg=micro... -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Outlook 2007 - import/export vCard problems | Mike | Outlook - Using Contacts | 4 | January 27th 07 06:38 AM |
| need to export firmwide contacts to access or any db | sammyl@gmail.com | Outlook - Using Contacts | 5 | January 8th 07 10:08 PM |
| Outlook Text Only Export into Access | LI_SpeedyG | Outlook and VBA | 1 | December 15th 06 06:12 PM |
| Tasks--Export to MS Access | craigs | Outlook and VBA | 2 | August 15th 06 03:49 PM |
| lousy Rules Alert features. | jack380 | Outlook - Installation | 1 | July 30th 06 02:17 PM |