mikolajek
Member
- OS Version(s)
- Windows
- Outlook version
- Outlook 365 64 bit
- Email Account
- Office 365 Exchange
Operating system:: Win11 Pro 25H2
Outlook version: 2510 build 19328.201
Email type or host: Microsoft 365
Outlook version: 2510 build 19328.201
Email type or host: Microsoft 365
I've been running the below macro for years already with my Outlook 365. It always worked as a charm.
After the latest Office update, it won't work anymore - it just randomly stops at different lines (mostly at the one marked in yellow).
Can someone review it and help me understand the possible reason?
After the latest Office update, it won't work anymore - it just randomly stops at different lines (mostly at the one marked in yellow).
Can someone review it and help me understand the possible reason?
Public Sub ChangeMailboxName()
Dim colStores As Outlook.Stores
Dim oStore As Outlook.Store
Dim oRoot As Outlook.Folder
Dim arrOldName As Variant
Dim arrNewName As Variant
' Set up the array
arrOldName = Array("email1", "email2")
arrNewName = Array("mailbox1", "mailbox2")
' Go through the array and look for a match, then do something
For i = LBound(arrOldName) To UBound(arrOldName)
Set colStores = Application.session.Stores
For Each oStore In colStores
Set oRoot = oStore.GetRootFolder
Debug.Print (oRoot)
If oRoot = arrOldName(i) Then
oRoot.Description = oRoot.Name
oRoot.Name = arrNewName(i)
End If
Next
'On Error Resume Next
Next i
Set oRoot = Nothing
Set oStore = Nothing
Set colStores = Nothing
End Sub