Problems with ContentControl object when code run from global macro workbook addin RRS feed

  • Question

  • I have the following piece of code that runs just fine as long as I run it from a VBA module in the Activedocument. But when I run the code from a global macro addin, the code always bombs out on line 240 with error 424, object required. Mind you, all the data I'm loading into the Dropdown list successfully loads. It appears to fail on exiting the For Each loop. Is there a know problem with utilizing content control objects from workbook addins? I'm out of ideas. Any suggestions would be appreciated.

    Update: Resolved. Misleading error code. Issue was indexing problem. "ctr +1" s/b "ctr".

          'Get set of tagged content controls
    40    Set oDocCCs = ActiveDocument.SelectContentControlsByTag("CompanyNames")
          'Process only if content control found
    50    If oDocCCs.Count > 0 Then
    60        sFile = "R:\Legal\Contracts\GTemplates\Names for Contract.txt"
    70        Open sFile For Input As #1
    80        sWhole = Input$(LOF(1), 1)
    90        Close #1
              'Clean end of string carriage return and line feed charaters
    100       Do Until Right(sWhole, 2) <> vbNewLine
    110           sWhole = Left(sWhole, Len(sWhole) - 2)
    120       Loop
              'Load variant array with string data
    130       aWendelCoData = Split(sWhole, vbNewLine)
              'Loop through content controls and load lists from array
    160       For Each oCC In oDocCCs
    170           oCC.DropdownListEntries.Clear
                  hold = aWendelCoData(ctr + 1)
    190           For ctr = 0 To UBound(aWendelCoData)
    210               oCC.DropdownListEntries.Add hold
    220           Next ctr
    240       Next oCC
    250   End If


    • Edited by phillfri Tuesday, June 7, 2016 5:31 AM
    Monday, June 6, 2016 7:57 PM


  • Hi phillfri,

    >> Update: Resolved. Misleading error code. Issue was indexing problem. "ctr +1" s/b "ctr".

    It seems your issue has been resolved, am I right? If so, I would suggest you post a new reply to post the solution, mark your reply as answer, and then others who run into the same issue would find the solution easily.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 7, 2016 6:37 AM