![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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\_MyExc elDoc.xls" strPath = "M:\Alcatel\Outside_Plant_Records\DBYD\Temp\_MyExc elDoc.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\Notificatio n\" & Atmt.FileName FileName = "M:\Alcatel\Outside_Plant_Records\DBYD\Notificatio n\" & Atmt.FileName Atmt.SaveAsFile FileName i = i + 1 Next Atmt Next Item End Sub "Alan" wrote: "Neil1958" wrote in message ... The saving of the actual email is still a question. A bit of back ground I receive an email in the same format each time and from the same source. I copy the body of the email into an excel sheet. By using the copy and paste function then excel automatically convert all the info into excel format. The data is then converted into one line in a database automatically. Is there a Marco to save the email? As you would do manually with "File" and "Save" from the menu. Like the attachment save macro you sent me. If not then what would be the Marco to copy the content of the email ready to paste. I use Ctrl/A and then Ctrl/C, from that I paste it into the excel clean up file directly as text. Then the macro can detach the attachments and I would have the email content ready yo paste into excel. I already have the macro in excel which takes it from the paste step through all the rest. Hi Neil, You can select multiple emails, the do File - Save (chose a path / name) and save them all as a single text file. Does that do what you need, or are you really needing to have copied the text in the emails to the clipboard? If the latter, then I am not sure. You can copy text in VBA, but I cannot get it to then paste to excel automagically. Perhaps I am missing something really obvious here! Perhaps the excel app needs to exist as an object in the outlook app and / or vice versa for it to work? I am not up on that kind of thing. Alan. |
Ads |
#2
|
|||
|
|||
![]()
Try using objItem instead of Item, since that's the variable that was declared.
-- 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 "SCrowley" wrote in message ... 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\_MyExc elDoc.xls" strPath = "M:\Alcatel\Outside_Plant_Records\DBYD\Temp\_MyExc elDoc.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\Notificatio n\" & Atmt.FileName FileName = "M:\Alcatel\Outside_Plant_Records\DBYD\Notificatio n\" & Atmt.FileName Atmt.SaveAsFile FileName i = i + 1 Next Atmt Next Item End Sub "Alan" wrote: "Neil1958" wrote in message ... The saving of the actual email is still a question. A bit of back ground I receive an email in the same format each time and from the same source. I copy the body of the email into an excel sheet. By using the copy and paste function then excel automatically convert all the info into excel format. The data is then converted into one line in a database automatically. Is there a Marco to save the email? As you would do manually with "File" and "Save" from the menu. Like the attachment save macro you sent me. If not then what would be the Marco to copy the content of the email ready to paste. I use Ctrl/A and then Ctrl/C, from that I paste it into the excel clean up file directly as text. Then the macro can detach the attachments and I would have the email content ready yo paste into excel. I already have the macro in excel which takes it from the paste step through all the rest. Hi Neil, You can select multiple emails, the do File - Save (chose a path / name) and save them all as a single text file. Does that do what you need, or are you really needing to have copied the text in the emails to the clipboard? If the latter, then I am not sure. You can copy text in VBA, but I cannot get it to then paste to excel automagically. Perhaps I am missing something really obvious here! Perhaps the excel app needs to exist as an object in the outlook app and / or vice versa for it to work? I am not up on that kind of thing. Alan. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
modification resolution | [email protected] | Outlook - Installation | 0 | April 30th 07 05:52 AM |
Calendar Renaming/Modification | UMN Dave | Outlook and VBA | 1 | February 26th 07 06:54 PM |
email message form modification | Secret Character | Outlook - Using Forms | 1 | December 14th 06 12:40 PM |
Moving Outlook to another PC, and moving data files to another location | /mel/ | Outlook - General Queries | 3 | June 24th 06 03:39 PM |
Outlook Archive Modification Date | eastcoasttech | Outlook - Installation | 1 | June 21st 06 07:43 PM |