Hallo lieber Thorsten ich hoffe du siehst diese Nachricht noch es ist ja schon einige Zeit her dass du Dirk geholfen hast. Ich habe das gleiche Problem. Ich habe mir ein Makro aus dem Netz zusammengebastelt das soweit prima funzt. Ich möchte die Anhänge der Emails (PDFs und Excels) in einen Ordner speichern. Leider überschreibt das Programm gleichgenannte Dateien. In meinem Makro ist ein lngCount enthalten, ich glaube das beißt sich mit dem Zähler. Könntest du dir es bitte mal anschauen? Du scheinst nett und freundlich zu sein manch andere sind da etwas ruppig und harsch... :)
Mein bisheriges Makro sieht so aus:
Public Sub SaveAttachments()
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem 'Object
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolderpath As String
Dim strDeletedFiles As String
' Get the path to your My Documents folder
strFolderpath = CreateObject("WScript.Shell").SpecialFolders(16)
On Error Resume Next
' Instantiate an Outlook Application object.
Set objOL = CreateObject("Outlook.Application")
' Get the collection of selected objects.
Set objSelection = objOL.ActiveExplorer.Selection
' The attachment folder needs to exist
' You can change this to another folder name of your choice
' Set the Attachment folder.
strFolderpath = strFolderpath & "\Türkei\"
' Check each selected item for attachments.
For Each objMsg In objSelection
Set objAttachments = objMsg.Attachments
lngCount = objAttachments.Count
If lngCount > 0 Then
' Use a count down loop for removing items
' from a collection. Otherwise, the loop counter gets
' confused and only every other item is removed.
For i = lngCount To 1 Step -1
' Get the file name.
strFile = objAttachments.Item(i).FileName
' Combine with the path to the Temp folder.
strFile = strFolderpath & strFile
' Save the attachment as a file.
objAttachments.Item(i).SaveAsFile strFile
Next i
End If
Next
ExitSub:
Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
End Sub
Ich hoffe du kannst mir helfen ich verstehe die Tipps der anderen nicht und denke wenn ich jetzt nur oben synchron überall Zähler einbaue wie bei Dirk geht es nicht. Anstelle von lngCount dass beißt sich ja oder?
Wenn nicht lasst mich es bitte wissen.
Nochmal vielen Dank im Vorraus und ein schönes Wochenende
|