Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default import outlook task to excel

This work on my machine, win xp with office xp. Anyone who see why it's not
working when i email it to a win98 machine, and runs it?

Dim olApp As Outlook.Application
Dim olNSpace As Outlook.NameSpace
Dim oltaskFolder As Outlook.MAPIFolder
Dim oltaskItem As Outlook.TaskItem
Dim wbBbok As Workbook
Dim wsSheet As Worksheet
Dim lnCount As Long, i As Long

Set olApp = CreateObject("Outlook.Application")
Set olNSpace = olApp.GetNamespace("MAPI")
Set oltaskFolder = olNSpace.GetDefaultFolder(olFolderTasks)

lnCount = oltaskFolder.Items.Count

If lnCount = 0 Then
MsgBox "Nothing to import", vbInformation
GoTo ErrorHandlerExit
End If

Set wbBbok = Application.ActiveWorkbook
Set wsSheet = wbBbok.Sheets("taskimport")

'Slett gamle data
With wsSheet
.Range("A2").CurrentRegion.ClearContents
.Range("A1:d1").Value = VBA.Array("task", "Tekst", "Alarm", "Status")
End With


i = 1
For Each oltaskItem In oltaskFolder.Items
i = i + 1

With wsSheet
.Cells(i, 2).Value = oltaskItem.Subject
.Cells(i, 4).Value = oltaskItem.Body
.Cells(i, 5).Value = oltaskItem.ReminderSet
.Cells(i, 6).Value = oltaskItem.Status
.Cells(i, 1).Value = oltaskItem.StartDate
End With

Next oltaskItem

With wsSheet
.Columns("A:K").EntireColumn.AutoFit
End With

ErrorHandlerExit:
Set oltaskItem = Nothing
Set oltaskFolder = Nothing
Set olNSpace = Nothing
Set olApp = Nothing
Exit Sub

ErrorHandler:
If Err.Number = 429 Then
Set olApp = CreateObject("Outlook.Application")
Resume Next
Else
MsgBox "Error No.: " & Err.Number & _
"; Description: " & Err.Description
End If
Resume ErrorHandlerExit
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default import outlook task to excel

stabekk

What about it doesn't work? Are you getting a specific error message?
Which version of Office is the Win98 machine running?

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"stabekk" wrote in message
...
This work on my machine, win xp with office xp. Anyone who see why it's

not
working when i email it to a win98 machine, and runs it?

Dim olApp As Outlook.Application
Dim olNSpace As Outlook.NameSpace
Dim oltaskFolder As Outlook.MAPIFolder
Dim oltaskItem As Outlook.TaskItem
Dim wbBbok As Workbook
Dim wsSheet As Worksheet
Dim lnCount As Long, i As Long

Set olApp = CreateObject("Outlook.Application")
Set olNSpace = olApp.GetNamespace("MAPI")
Set oltaskFolder = olNSpace.GetDefaultFolder(olFolderTasks)

lnCount = oltaskFolder.Items.Count

If lnCount = 0 Then
MsgBox "Nothing to import", vbInformation
GoTo ErrorHandlerExit
End If

Set wbBbok = Application.ActiveWorkbook
Set wsSheet = wbBbok.Sheets("taskimport")

'Slett gamle data
With wsSheet
.Range("A2").CurrentRegion.ClearContents
.Range("A1:d1").Value = VBA.Array("task", "Tekst", "Alarm", "Status")
End With


i = 1
For Each oltaskItem In oltaskFolder.Items
i = i + 1

With wsSheet
.Cells(i, 2).Value = oltaskItem.Subject
.Cells(i, 4).Value = oltaskItem.Body
.Cells(i, 5).Value = oltaskItem.ReminderSet
.Cells(i, 6).Value = oltaskItem.Status
.Cells(i, 1).Value = oltaskItem.StartDate
End With

Next oltaskItem

With wsSheet
.Columns("A:K").EntireColumn.AutoFit
End With

ErrorHandlerExit:
Set oltaskItem = Nothing
Set oltaskFolder = Nothing
Set olNSpace = Nothing
Set olApp = Nothing
Exit Sub

ErrorHandler:
If Err.Number = 429 Then
Set olApp = CreateObject("Outlook.Application")
Resume Next
Else
MsgBox "Error No.: " & Err.Number & _
"; Description: " & Err.Description
End If
Resume ErrorHandlerExit
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sync between table in excel to task list in outlook ayelet Excel Discussion (Misc queries) 0 August 31st 08 06:19 AM
Import Task information from Excel to Outlook scott56hannah Excel Discussion (Misc queries) 1 October 7th 07 03:15 PM
Creating a task in Outlook from a date in Excel Jamie@Wildcard Excel Discussion (Misc queries) 3 July 3rd 07 04:54 PM
How can i have Excel automatically set an Outlook task? VT Excel Discussion (Misc queries) 0 July 31st 06 11:49 AM
Can I create a button in Excel that generates a task in Outlook? Tio777 Excel Discussion (Misc queries) 1 June 15th 05 03:41 PM


All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"