S
SCrowley
From a post on 9.13.2005 the below thread was discussed. I am trying to
modify the suggested code to work for me in Outlook 2003 (11.8118.8122) SP2,
Office Professional edition.
When I try to run the macro it has a Compile Error: Can't find project or
library for the strname portion of this line
strname = Item.Subject
I have looked in the object brower and can not locate where this might be.
Any suggestions are most welcomed
Allans thanks for pointing me the right direction.
Below is my final code
It runs this on all emails in the inbox:
Copies the body of the email to to seperate new excel fromat files in a set
directory.
Deattaches all attachment to a directory
Makes a file of the all emails file name which were converted. This file is
then used to bring all the above data back together in one data base.
Thanks for your help
Hvae a good day
Sub SetupALL()
' work on this one for excel.
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Dim test As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
test = 0
Dim objItem As Object
Dim MyItem1 As Outlook.Inspector
Dim strPath As String
Dim ExcelApp As Object
Dim ExcelSheet As Object
Dim olApp As New Outlook.Application
Dim doc As Object
test = 1
'strPath = "D:\temp\_MyExcelDoc.xls"
'strPath = "G:\Alcatel\Outside_Plant_Records\DBYD\Temp\_MyExcelDoc.xls"
strPath = "M:\Alcatel\Outside_Plant_Records\DBYD\Temp\_MyExcelDoc.xls"
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelSheet = ExcelApp.Workbooks.Add
For Each Item In Inbox.Items
strname = Item.Subject
ExcelSheet.ActiveSheet.Cells(test, 1).Value = Mid(strname, 5, 7)
'Item.SaveAs "d:\temp\" & Mid(strname, 5, 7) & ".xls", olTXT
'Item.SaveAs "G:\Alcatel\Outside_Plant_Records\DBYD\Temp\" &
Mid(strname, 5, 7) & ".xls", olTXT
Item.SaveAs "M:\Alcatel\Outside_Plant_Records\DBYD\Temp\" & Mid(strname,
5, 7) & ".xls", olTXT
test = test + 1
i = i + 1
Next Item
ExcelSheet.SaveAs strPath
ExcelApp.Quit
Set ExcelApp = Nothing
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
'FileName = "D:\temp\" & Atmt.FileName
'FileName = "G:\Alcatel\Outside_Plant_Records\DBYD\Notification\" &
Atmt.FileName
FileName = "M:\Alcatel\Outside_Plant_Records\DBYD\Notification\" &
Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
Next Item
End Sub
modify the suggested code to work for me in Outlook 2003 (11.8118.8122) SP2,
Office Professional edition.
When I try to run the macro it has a Compile Error: Can't find project or
library for the strname portion of this line
strname = Item.Subject
I have looked in the object brower and can not locate where this might be.
Any suggestions are most welcomed
Allans thanks for pointing me the right direction.
Below is my final code
It runs this on all emails in the inbox:
Copies the body of the email to to seperate new excel fromat files in a set
directory.
Deattaches all attachment to a directory
Makes a file of the all emails file name which were converted. This file is
then used to bring all the above data back together in one data base.
Thanks for your help
Hvae a good day
Sub SetupALL()
' work on this one for excel.
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Dim test As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
test = 0
Dim objItem As Object
Dim MyItem1 As Outlook.Inspector
Dim strPath As String
Dim ExcelApp As Object
Dim ExcelSheet As Object
Dim olApp As New Outlook.Application
Dim doc As Object
test = 1
'strPath = "D:\temp\_MyExcelDoc.xls"
'strPath = "G:\Alcatel\Outside_Plant_Records\DBYD\Temp\_MyExcelDoc.xls"
strPath = "M:\Alcatel\Outside_Plant_Records\DBYD\Temp\_MyExcelDoc.xls"
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelSheet = ExcelApp.Workbooks.Add
For Each Item In Inbox.Items
strname = Item.Subject
ExcelSheet.ActiveSheet.Cells(test, 1).Value = Mid(strname, 5, 7)
'Item.SaveAs "d:\temp\" & Mid(strname, 5, 7) & ".xls", olTXT
'Item.SaveAs "G:\Alcatel\Outside_Plant_Records\DBYD\Temp\" &
Mid(strname, 5, 7) & ".xls", olTXT
Item.SaveAs "M:\Alcatel\Outside_Plant_Records\DBYD\Temp\" & Mid(strname,
5, 7) & ".xls", olTXT
test = test + 1
i = i + 1
Next Item
ExcelSheet.SaveAs strPath
ExcelApp.Quit
Set ExcelApp = Nothing
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
'FileName = "D:\temp\" & Atmt.FileName
'FileName = "G:\Alcatel\Outside_Plant_Records\DBYD\Notification\" &
Atmt.FileName
FileName = "M:\Alcatel\Outside_Plant_Records\DBYD\Notification\" &
Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
Next Item
End Sub