![]() ![]() ' // Loop through the Items in the folder backwards Set myFolder = olNs.GetDefaultFolder(olFolderInbox) MsgBox "Excel table does not have rows.", vbCritical, "Error" MsgBox "Activesheet did not have the Excel table containing Subjects and Outlook Folder Names", vbCritical, "Error"Īrr = WS.ListObjects(1).DataBodyRange.Value 'arr will be a 2D array sitting in an Excel file, 1st col=subject, 2nd col=folder nameĭim arr() As Variant 'store Excel table as an array for faster iterations Paste this code in there: Option Explicit On the left panel (project explorer) right click and insert a module. Go to the excel file that you have your subject and folders list or create a new one. Here is the code and how you should use it: You have few options to do this, the painless one is to run Outlook VBA code from inside outlook so you don't need to go through a lot of referencing problem, but at the same time if you are insisting in having your list of subjects and folder in an Excel file, then it is better to run it from Excel, but here is the issue: You'd better not try to run the code from Excel because Microsoft is not supporting that method, so the best way is to write the code in Excel VBA, and again you can do late (runtime) binding or early binding, but I prefer early binding to use intellisence for better referencing outlook objects and avoid late binding performance and/or debugging problems. How do I loop? to look at the Sheet1 and to read to which sub folder it has to move ? I want the code to read the active sheet columns, as follow: Subject.mail folder_nameįor example Mail in the Inbox with subject "A" then it has to place that mail in folder "1". & vbCrLf & "Error Description: " & Err.Description _ ![]() & vbCrLf & "Error Number: " & Err.Number _ MsgBox "An unexpected Error has occurred." _ '// Loop through the Items in the folder backwards ![]() Set Inbox = olNs.GetDefaultFolder(olFolderInbox) Set olNs = Application.GetNamespace("MAPI") I have already this code from Stackoverflow Option Explicit I have a Excel Sheet which has subject and Folder Name. ![]() My mails in Outlook has all specific subjects. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |