How to Get Warned before Moving a Non-Empty Folder in Your Outlook

If you frequently move folders mistakenly in your Outlook, you must hope to get warned at that time. This article will teach you how to let Outlook alert you before moving a non-empty folder.

As we all know, when you delete a folder in your Outlook, you will definitely get a warning asking if you are sure to delete it and move all its items to Deleted Items. Similar to this warning, you may desire that Outlook can also warn you when you move folders in that you frequently move folders by accident and mistake. Apart from selecting “Move Folder” in the right clicking menu, you can simply drag and drop the folder to move it. Therefore, this process is quite error prone. In face of this issue, you can use the following means to make Outlook warn you before you move a non-empty folder.

Get Warned before Moving a Non-Empty Folder in Your Outlook

Get Warned before Moving a Non-Empty Folder

  1. In the first place, start your Outlook program.
  2. Then in Outlook window, shift to “Developer” tab and click on “Visual Basic” button.
  3. Subsequently, in the Outlook VBA editor window, open “ThisOutlookSession” project.
  4. Next you can copy the following VBA codes to this project window.
Private WithEvents objExplorer As Outlook.Explorer
Private WithEvents objCurrentFolder As Outlook.Folder

Private Sub Application_Startup()
    Set objExplorer = Outlook.Application.ActiveExplorer
End Sub

Private Sub objExplorer_Activate()
    'Get the currently selected folder
    Set objCurrentFolder = objExplorer.CurrentFolder
End Sub

Private Sub objCurrentFolder_BeforeFolderMove(ByVal MoveTo As MAPIFolder, Cancel As Boolean)
    Dim strMsg As String
    Dim nResponse As Integer
    'If the current folder is not empty
    If objCurrentFolder.Items.Count > 0 Then
       'Get a warning
       strMsg = "This folder " & Chr(34) & objCurrentFolder.Name & Chr(34) & " contains items. Are you sure to move it?"
       nResponse = MsgBox(strMsg, vbExclamation + vbYesNo, "Confirm Folder Move/Delete")
       If nResponse = vbYes Then
          Cancel = False
          Cancel = True
       End If
    End If
End Sub

VBA Code - Get Warned before Moving a Non-Empty Folder

  1. After that, you ought to sign this code.
  2. Later you need to change your Outlook macro settings to permit the digitally signed VBA projects.
  3. Eventually you can restart your Outlook application to activate the macro.
  4. From now on, every time when you try to move a non-empty folder, you will get a warning like the following screenshot:

Not Immune from PST Corruption

Though Outlook comes with a lot of powerful features, it doesn’t mean that it will never get damaged. Therefore, you still should pay much attention to protecting your PST file, for instance sticking to the plan of making regular data backups or keeping a potent repair took in vicinity like DataNumen Outlook Repair, which is able to fix Outlook troubles without breaking a sweat.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including fix mdf and outlook repair software products. For more information visit

Comments are closed.