title: Excel VBA, set an Outlook Folder, which is a public folder
body: <p>I'm trying to move emails from an inbox folder (named "A_Classer") into a Outlook public folder (variable name for the destination folder is olFolder)
  I tried the getshareddefaultfolder method and the OpenSharedFolder method but I couldn't solve my syntax problem
  The name of the shared folder is "Québec"  and it's path (from the property Windows) is ("Dossiers publics - guillaume.hebert@cima.ca/Tous les dossiers publics/Québec")
  Code stops at :  set olFolder...</p>
  
  <p>Here's my code below with all the versions I tried</p>
  
  <pre><code>Sub move_to_public_folder()
  
  Dim msg As Outlook.MailItem
  Dim olFolder As Outlook.Folder         'public folder where I want the email to be moved
  Dim sourceFolder As Outlook.Folder           'current folder of the emails that are to be moved
  Dim OlApp As Object
  
  Dim myNamespace As Outlook.Namespace
  Dim myRecipient As Outlook.Recipient
  
  Set OlApp = CreateObject("Outlook.Application")                         'Outlook application call
  Set myNamespace = OlApp.GetNamespace("MAPI")
  
  Set myRecipient = myNamespace.CreateRecipient("Guillaume Hébert")
  myRecipient.Resolve
  If myRecipient.Resolved Then
      Cells(1, 1) = Cells(1, 1) + 1
  End If
  
  Set olFolder = myNamespace.OpenSharedFolder("Québec")            'FIRST try I made
  'Set olFolder = myNamespace.OpenSharedFolder _                    'Second try I made
      '("Dossiers publics - guillaume.hebert@cima.ca/Tous les dossiers publics/Québec")
  'Set olFolder = myNamespace.GetSharedDefaultFolder _              'Last try I made
                      '(myRecipient, olPublicFoldersAllPublicFolders)
  
  
  
  Set sourceFolder = Session.GetDefaultFolder(sourceFolderInbox)
  Set sourceFolder = sourceFolder.Folders("A_Classer")
  If sourceFolder Is Nothing Then Exit Sub
  
  I = sourceFolder.Items.Count
  nbre_op = I                                                         'détermine combien de courriel dans le répertoire
  I = 1
  While I &lt;= nbre_op
      Set msg = olFolder.Items(1)
      msg.Move olFolder
      I = I + 1
  Wend
  
  Set OlApp = Nothing
  </code></pre>
  
  <p>End Sub</p>
  
  <p>Thank you in advance for all the help you will kindly provide</p>