Export Folders and Sub Folders data to Excel

dededepk

New Member
Joined
Aug 8, 2017
Messages
1
Hello guys,I have this code which serves to copy the information of the mails of the folders and subfolders that I have selected.But what I want is that in line 1 only the name of the second folder comes out. What happens is that I have the main folder that is "Advisors" and inside that folder is the sub folder with the name of each advisor, inside those subfolders are folders with categorized emails.

Picked folder\Second folder(What i need)\ other sub folder\etc...

I need your help.Sorry for the bad english




Public xlSht As Excel.Worksheet


Sub DocumentFolders(objParent As folder, lRow As Long)
Dim objItm As Object
Dim objFolder As folder

On Error Resume Next
With xlSht
For Each objItm In objParent.Items
.Cells(lRow, 1) = objParent
.Cells(lRow, 2) = objItm.SenderEmailAddress
.Cells(lRow, 3) = objItm.Subject
.Cells(lRow, 4) = objItm.ReceivedTime
.Cells(lRow, 5) = objItm.Categories
lRow = lRow + 1
Next
End With
On Error GoTo 0

If objParent.folders.Count > 0 Then
For Each objFolder In objParent.folders
Call DocumentFolders(objFolder, lRow)
Next
End If




End Sub




Sub Exportar_datos()
Dim xlApp As Excel.Application
Dim xlWb As Excel.Workbook
Dim folder






Set xlApp = New Excel.Application
Set xlWb = xlApp.Workbooks.Add
Set xlSht = xlWb.Sheets(1)

With xlSht
.Cells(1, 1) = "Carpeta"
.Cells(1, 2) = "Correo"
.Cells(1, 3) = "Asunto"
.Cells(1, 4) = "Hora"
.Cells(1, 5) = "Categoría"
End With


Call DocumentFolders(Session.PickFolder(), 2)

xlApp.Visible = True




Set xlSht = Nothing
Set xlWb = Nothing
Set xlApp = Nothing




End Sub
****** id="cke_pastebin" style="position: absolute; top: 8px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">Hello boys,I have this code which serves to copy the information of the mails of the folders and subfolders that I have.But what I want is that in line 1 only the name of the second folder comes out. What happens is that I have the main folder that is "Advisors" and inside that folder is the sub folder with the name of each advisor, inside those subfolders are folders with categorized emails.I need your help.Sorry for the bad english</body>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,215,543
Messages
6,125,429
Members
449,223
Latest member
Narrian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top