Hallo,
ich habe hier ein Macro mit dem ich eMails speichern kann. Es funzt auch super, nur ist mir das Fenster zur Auswahl des Speicherortes zu klein. Könnte mir bitte jemand schreiben wie, wo und was geändert werden muß um das Fenster zu vergrößern!?
Danke
-----------------------------------------------------------------------------------------
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Public Const BIF_RETURNONLYFSDIRS = 1
Public Const MAX_PATH = 260
Public Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Sub SpeichernalsMSG()
Dim myExplorer As Outlook.Explorer
Dim myfolder As Outlook.MAPIFolder
Dim strname As String
Dim myItem As MailItem
Dim olSelection As Selection
Dim strBackupPath As String
Set myExplorer = Application.ActiveExplorer
Set myfolder = myExplorer.CurrentFolder
If Not myfolder.DefaultItemType = olMailItem Then GoTo Ende
strBackupPath = GetFileDir
Set olSelection = myExplorer.Selection
For Each myItem In olSelection
strname = Format(myItem.ReceivedTime, "dd-mm-yyyy hh-nn-ss") _
& "__" & myItem.SentOnBehalfOfName & "__" & IIf(Len(strBackupPath & myItem.Subject & myItem.SentOnBehalfOfName) > 255, _
Left(myItem.Subject, 255 - Len(strBackupPath)), myItem.Subject) & ".msg"
myItem.SaveAs strBackupPath & "\" & CleanString(strname), olMSG
Next
Ende:
End Sub
Private Function CleanString(strData As String) As String
'Replace invalid strings.
strData = ReplaceChar(strData, "´", "_")
strData = ReplaceChar(strData, "`", "_")
strData = ReplaceChar(strData, "'", "_")
strData = ReplaceChar(strData, "{", "(")
strData = ReplaceChar(strData, "[", "(")
strData = ReplaceChar(strData, "]", ")")
strData = ReplaceChar(strData, "}", ")")
strData = ReplaceChar(strData, "/", "-")
strData = ReplaceChar(strData, "\", "-")
strData = ReplaceChar(strData, ":", "")
'Cut out invalid signs.
strData = ReplaceChar(strData, "*", "_")
strData = ReplaceChar(strData, "?", "")
strData = ReplaceChar(strData, """", "_")
strData = ReplaceChar(strData, "<", "")
strData = ReplaceChar(strData, ">", "")
strData = ReplaceChar(strData, "|", "")
CleanString = Trim(strData)
End Function
Private Function ReplaceChar(strData As String, strBadChar As String, strGoodChar As String) As String
Dim tmpChar As String
Dim tmpString As String
Dim i As Long
For i = 1 To Len(strData)
tmpChar = Mid(strData, i, 1)
If tmpChar = strBadChar Then
tmpString = tmpString & strGoodChar
Else
tmpString = tmpString & tmpChar
End If
Next i
ReplaceChar = Trim(tmpString)
End Function
Public Function GetFileDir() As String
Dim ret As String
Dim lpIDList As Long
Dim sPath As String, udtBI As BrowseInfo
Dim RdStrings() As String, nNewFiles As Long
'Show a browse-for-folder form:
With udtBI
.lpszTitle = lstrcat("Bitte wählen Sie den Ordner zum Exportieren:", "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With
lpIDList = SHBrowseForFolder(udtBI)
If lpIDList = 0 Then Exit Function
'Get the selected folder.
sPath = String$(MAX_PATH, 0)
SHGetPathFromIDList lpIDList, sPath
CoTaskMemFree lpIDList
sPath = StripNulls(sPath)
GetFileDir = sPath
End Function
Public Function StripNulls(ByVal OriginalStr As String) As String
If (InStr(OriginalStr, Chr$(0)) > 0) Then
OriginalStr = Left$(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
End If
StripNulls = OriginalStr
End Function
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP