title: Move emails to a different data/PST file
body: <p>I have edited a script I found online to move email to various folders. </p>
  
  <p>I want to take it a step further to move emails to a folder within a separate PST file.  </p>
  
  <p>This will be running in Outlook 2007.</p>
  
  <p>The macro stems from this Macro that is titled "Updated" and is the cleaner version:<br>
  <a href="http://jmerrell.com/2011/05/21/outlook-macros-move-email" rel="nofollow noreferrer">http://jmerrell.com/2011/05/21/outlook-macros-move-email</a></p>
  
  <p>I'm almost certain this link holds the clue, but I don't have the experience to apply it properly:<br>
  <a href="http://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/" rel="nofollow noreferrer">http://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/</a></p>
  
  <p>My current Macro allows emails to be moved to 3 different folder locations within the main PST "Inbox" folder.</p>
  
  <pre><code>'Outlook VB Macro to move selected mail item(s) to a target folder
  Sub MoveToFolder(targetFolder)
  On Error Resume Next
  
  Dim ns As Outlook.NameSpace
  Dim MoveToFolder As Outlook.MAPIFolder
  Dim objItem As Outlook.MailItem
  
  Set ns = Application.GetNamespace("MAPI")
  
  'define path to the target folder; the following assumes the target folder
  'is a sub-folder of the main Mailbox folder
  
  'This is the original'
  'Set MoveToFolder = ns.Folders("Mailbox").Folders(targetFolder)'
  Set MoveToFolder = ns.GetDefaultFolder(olFolderInbox).Folders(targetFolder)
  
  
  If Application.ActiveExplorer.Selection.Count = 0 Then
      MsgBox ("No item selected")
      Exit Sub
  End If
  
  If MoveToFolder Is Nothing Then
      MsgBox "Target folder not found!", vbOKOnly + vbExclamation, "Move Macro Error"
  End If
  
  For Each objItem In Application.ActiveExplorer.Selection
      If MoveToFolder.DefaultItemType = olMailItem Then
          If objItem.Class = olMail Then
              objItem.Move MoveToFolder
          End If
      End If
  Next
  
  Set objItem = Nothing
  Set MoveToFolder = Nothing
  Set ns = Nothing
  
  End Sub
  
  Sub MoveToActive()
  MoveToFolder ("Active")
  End Sub
  
  Sub MoveToAction()
  MoveToFolder ("Action")
  End Sub
  
  Sub MoveToOnHold()
  MoveToFolder ("OnHold")
  End Sub
  </code></pre>
  
  <hr>
  
  <p>How do I configure a 4th option to move an email to a folder within a different PST?</p>
  
  <p>For example I would like to add an extra button called "Archive", and when this particular button is clicked it will move the email to the archive folder within the separate PST's Inbox.</p>
  
  <pre><code>Sub MoveToArchive()
  MoveToFolder ("Archive")
  End Sub
  </code></pre>