Advertisement
Guest User

VBA

a guest
Mar 14th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Sub test()
  3.    Dim olApp As Object, NS As Object, Dossier As Object
  4.     Dim DossierDest As Object, DossierCible As Object
  5.    
  6.     Dim i As Object, x As Long, R As Object, Ligne As Long
  7.    
  8.     Set olApp = CreateObject("Outlook.Application")
  9.     Set NS = olApp.GetNamespace("MAPI")
  10.     Set Inbox = NS.GetDefaultFolder(olFolderInbox)
  11.     Set Dossier1 = Inbox.Folders("cs-compteurs-coul")
  12.     Set Dossier2 = Inbox.Folders("cs-compteurs-noir")
  13.     Set DossierDest = Inbox.Folders("compteurs-OK")
  14. With Sheets("Import Compteurs")
  15. b = 2
  16. Z = 2
  17.     For Each i In Dossier1.Items
  18.  
  19.             mybody = Split(i.Body, vbCrLf)
  20.             For compt = 0 To UBound(mybody)
  21.             If InStr(1, UCase(mybody(compt)), UCase("Serial No.:")) > 0 Then
  22.                 Serial = LTrim(Split(mybody(compt), ":")(1))
  23.             End If
  24.             If InStr(1, UCase(mybody(compt)), UCase("Date:")) > 0 Then
  25.                 Dat = i.CreationTime
  26.             End If
  27.             If InStr(1, UCase(mybody(compt)), UCase("Total_Color:")) > 0 Then
  28.                 Couleur = LTrim(Split(mybody(compt), ":")(1))
  29.             End If
  30.             If InStr(1, UCase(mybody(compt)), UCase("Total_BW:")) > 0 Then
  31.                 Noir = LTrim(Split(mybody(compt), ":")(1))
  32.             End If
  33.     Next
  34. Dat = i.CreationTime
  35. Cells(b, 1) = Serial
  36. Cells(b, 2) = Dat
  37. Cells(b, 3) = Noir
  38. Cells(b, 4) = Couleur
  39.        
  40. b = b + 1
  41.  
  42. Z = Z + 1
  43. Next i
  44.  
  45. d = 0
  46. For d = 0 To Z
  47. For Each i In Dossier1.Items
  48. i.Move DossierDest
  49. d = d + 1
  50. Next i
  51.  
  52. Next
  53.  
  54.  
  55.  
  56.  
  57. End With
  58.  
  59.  
  60. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement