title: How to determine CC / BCC selection using VBA GetSelectNameDialog from Global Address List
body: <p>Hi knowledgeable people!</p>
  
  <h2>Background:</h2>
  
  <p>I am developing a custom mail merge tool in MS Word VBA for our team so that we have extra functionality beyond the standard Office Word mail merge package. 3rd party products or add-ons are <strong><em>not</em></strong> possible. But, the ability to automatically attach specific files, custom subject line etc, would save us a lot of time and effort.</p>
  
  <p>One of the features is to enable the user to select additional carbon-copy (CC) or blind carbon-copy (BCC) email accounts to append to the mail merge from our corporate Microsoft Exchange Global Address List (GAL). The user may need to select multiple CC or BCC email accounts.</p>
  
  <h2>Problem:</h2>
  
  <p>Using a previous question &amp; answer (<a href="https://stackoverflow.com/questions/30918152/opening-outlook-address-book-from-excel">30918152</a>) I was able to call the address book GAL and customise the <em>To:</em> / <em>CC:</em> / <em>BCC:</em> labels. The code is able to retrieve the selected exchange accounts in the <code>.Recipients</code> collection, but <strong>I am struggling to determine which selections are CC or BCC.</strong></p>
  
  <p>I am aware that <code>Outlook.Recipient.Type</code> returns a variable type <em>Long</em>, which relates to From: / To: / CC: / BCC: 
  But, when I <code>debug.print 'recipient.type'</code> always returns 1 even when CC or BCC is selected.</p>
  
  <p><strong>Does anyone know where I am going wrong?</strong></p>
  
  <h2>Progress so far:</h2>
  
  <p>I have searched MSDN, run multiple web searches and scoured places like Stack Overflow, VBOffice.net, but haven't what I'm looking for. I am self-taught, so suspect my fundamental problem is lack of understanding of the MSDN page on <a href="https://docs.microsoft.com/en-us/office/vba/api/outlook.selectnamesdialog.recipients" rel="nofollow noreferrer">SelectNamesDialog.Recipients</a></p>
  
  <h2>Code:</h2>
  
  <pre><code>Private Sub cmdSetProjectMember1_Click()
  ' CODE TO SELECT FROM ADDRESS BOOK AND TAKE EMAIL ADDRESS WHEN IT IS AN EXCHANGE USER.
  ' TAKEN FROM https://stackoverflow.com/questions/30918152/opening-outlook-address-book-from-excel
  
    Dim olApp As Outlook.Application
    Dim oDialog As SelectNamesDialog
    Dim oGAL As AddressList
    Dim myAddrEntry As AddressEntry
    Dim exchUser As Outlook.ExchangeUser
    Dim TEST_Recipient As Outlook.Recipient
  
    Dim AliasName As String
    Dim FirstName As String
    Dim LastName As String
    Dim EmailAddress As String
  
      Set aOutlook = GetObject(, "Outlook.Application")
      Set oDialog = aOutlook.Session.GetSelectNamesDialog
      Set oGAL = aOutlook.GetNamespace("MAPI").AddressLists("Global Address List")
  
      With oDialog
          .AllowMultipleSelection = True
          .InitialAddressList = oGAL
          .ShowOnlyInitialAddressList = True
          .Caption = "Custom mail merge tool  *****  | |  *****  SELECT EMAIL FROM ADDRESS BOOK"
          .NumberOfRecipientSelectors = olShowToCc
          .ToLabel = "Select CC:"
          .CcLabel = "Select BCC:"
  
          If .Display Then
                  AliasName = oDialog.Recipients.Item(1).Name
                  Set myAddrEntry = oGAL.AddressEntries(AliasName)
                  Set exchUser = myAddrEntry.GetExchangeUser
  
                  If Not exchUser Is Nothing Then
                      FirstName = exchUser.FirstName
                      LastName = exchUser.LastName
                      EmailAddress = exchUser.PrimarySmtpAddress
  
                      'MsgBox "You selected contact: " &amp; vbNewLine &amp; _
                          '"FirstName: " &amp; FirstName &amp; vbNewLine &amp; _
                          '"LastName:" &amp; LastName &amp; vbNewLine &amp; _
                          '"EmailAddress: " &amp; EmailAddress
  
                  Set TEST_Recipient = oDialog.Recipients.Item(1)
                   Debug.Print TEST_Recipient.Type
  
                   If TEST_Recipient.Type = olCC Then
                      MsgBox "Carbon Copy"
  
                  Else
                      MsgBox "NOT CC"
  
                  End If
  
              End If
  
          End If
  
      End With
  
   Set olApp = Nothing
   Set oDialog = Nothing
   Set oGAL = Nothing
   Set myAddrEntry = Nothing
   Set exchUser = Nothing
  
  End Sub
  </code></pre>