Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FindControl not working (Excel 2000 - 2007)

    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).en able = False

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FindControl not working (Excel 2000 - 2007)

    Use

    Application.CommandBars.FindControl(ID:=30095).Ena bled = True

    or simply

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

    (Note the use of Enabled instead of enable)

  3. #3
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FindControl not working (Excel 2000 - 2007)

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

    As always Hans thank you!!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FindControl not working (Excel 2000 - 2007)

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •