![]() |
|
Forum
|
|
|
#1 (permalink) |
|
Guest
Messages: n/a
|
Bonjour tout le monde.
Est ce que quelqu'um peut me dire ou dois je exécuter cette macro que j'ai récupérer sur le forum : sous outlook ou sous Excel ? Cette macro permet de lister les mails de la boîte de réception dans une feuille excel mais Problème : Sous Excel : Outlook.MAPIFolder : objet inconu Sous Outlook : Range("A1:G1") : fonction non définie Merci beaucoup à tous ceux qui me donneront un peu de leur temps. Voici la macro : Sub ListAllItemsInInbox() Dim OLF As Outlook.MAPIFolder, CurrUSer As String Dim EmailItemCount As Integer, i As Integer, emailcount As Integer Application.Calculation = xlCalculationManual 'Application.ScreenUpdating = False: 'On Error Resume Next 'Sheets("Courrier").Select ActiveSheet.Select Cells.Delete: ActiveSheet.Buttons.Delete: ActiveSheet.DropDowns.Delete Cells.RowHeight = 21.5: Columns(7).ColumnWidth = 20 Range("A1:G1").Font.Bold = True: Range("A1:G1").Font.Size = 12 Cells(1, 1).Formula = "De" Cells(1, 2).Formula = "Sujet" Cells(1, 3).Formula = "Date" Cells(1, 4).Formula = "Annexes" Cells(1, 5).Formula = "Lu ?" Cells(1, 7).Formula = "Ouvrir les annexes" 'Selection.AutoFormat Format:=xlRangeAutoFormatClassic2, Number:=True, _ Font:=True, Alignment:=True, Border:=True, Pattern:=True, Width:=True Set OLF = GetObject("", "Outlook.Application").GetNamespace("MAPI").GetDef aultFolder(olFolderInbox) EmailItemCount = OLF.Items.Count i = 0: emailcount = 0 ' read e-mail information While i < EmailItemCount i = i + 1 If i Mod 50 = 0 Then Application.StatusBar = "Reading e-mail messages " & Format(i / EmailItemCount, "0%") & "..." With OLF.Items(i) emailcount = emailcount + 1 Cells(emailcount + 1, 2).Formula = .Subject Cells(emailcount + 1, 1).Formula = .SenderName Cells(emailcount + 1, 3).Formula = Format(.ReceivedTime, "dd.mm.yyyy hh:mm") Cells(emailcount + 1, 4).Formula = .Attachments.Count Cells(emailcount + 1, 5).Formula = Not .UnRead 'créer un bouton Cells(emailcount + 1, 5).Select ActiveSheet.Buttons.Add(1, 1, Selection.Width, Selection.Height).Select Selection.Name = "Btn" & (emailcount + 1) ActiveSheet.Buttons("Btn" & (emailcount + 1)).Top = Cells(emailcount + 1, 6).Top ActiveSheet.Buttons("Btn" & (emailcount + 1)).Left = Cells(emailcount + 1, 6).Left Selection.OnAction = "lire_fichier" Cells(emailcount + 1, 7).Select ActiveSheet.DropDowns.Add(1, 1, Selection.Width, Selection.Height).Select Selection.Name = "DropD" & (emailcount + 1) Selection.LinkedCell = ActiveSheet.Range("G" & emailcount + 1).Address ActiveSheet.DropDowns("DropD" & (emailcount + 1)).Top = Cells(emailcount + 1, 7).Top ActiveSheet.DropDowns("DropD" & (emailcount + 1)).Left = Cells(emailcount + 1, 7).Left Selection.OnAction = "go_fichier" End With If OLF.Items(i).Attachments.Count <> "" Then For j = 1 To OLF.Items(i).Attachments.Count nomfichier = OLF.Items(i).Attachments.Item(j) ActiveSheet.DropDowns("DropD" & (emailcount + 1)).AddItem nomfichier Next j End If Wend Application.Calculation = xlCalculationAutomatic Range("G2") = OLF.UnReadItemCount Set OLF = Nothing Columns("A:E").AutoFit Range("A2").Select ActiveWindow.FreezePanes = True ' ActiveWorkbook.Saved = True Application.StatusBar = False End Sub |
| ANNONCES | |||
|
|
|
|
#3 (permalink) |
|
Guest
Messages: n/a
|
Merci beaucoup pour l'info !
Ces mes débuts de VBA avec Excel + Outlook comme tu as pu le remarquer. Et d'ailleurs, j'ai toujours un soucis : La déclaration suivante est toujours inconnu sous Excel : Dim corps As DataObject Ai je oublié de déclarer une autre référence. Merci beaucoup |
| ANNONCES | |
| Liens sociaux |
| Outils de la discussion | |
|
|