• FindControl not working (Excel 2000 – 2007)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » FindControl not working (Excel 2000 – 2007)

    Author
    Topic
    #454270

    The following line in the ThisWorkbook class fails returning an error message that an object is not set. Adding ThisWorkbook to the watch window says it is out of context. The 30095 refers to the File | Send to menu item. This works fine when used with Word but using ThisDocument of course. Is there some other way one must do this when using Excel? The use of the ID number is because the workbook is being used in a French version of Excel.

    ThisWorkbook.CommandBars.FindControl(ID:=30095).enable = False

    Viewing 0 reply threads
    Author
    Replies
    • #1127203

      Use

      Application.CommandBars.FindControl(ID:=30095).Enabled = True

      or simply

      CommandBars.FindControl(ID:=30095).Enabled = True

      (Note the use of Enabled instead of enable)

      • #1127204

        Thank you Hans. The enable was a typo. Based on your reply I see now I can also use ThisWorkbook.Application.CommandBars.FindControl(ID:=30095).Enabled = True . Why the need for the application level since FindControl exists at just the TisWorkbook level?

        As always Hans thank you!!

        • #1127205

          Although CommandBars is a property of both the Application object and of the Workbook object, the VBA help in my version of Excel (Excel 2002 SP3 Dutch) says that it should only be used as a property of the Workbook object when a workbook embedded in another application is opened by double-clicking. In all other situations, CommandBars as property of a Workbook returns Nothing.

    Viewing 0 reply threads
    Reply To: FindControl not working (Excel 2000 – 2007)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: