Results 1 to 23 of 23

Disable ribbon element if workbook doesnt contain a specific worksheet

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    03-17-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    2007/2010
    Posts
    555

    Disable ribbon element if workbook doesnt contain a specific worksheet

    Hi all,

    I think I'm pretty close to figuring this one out, but I still need an experts opinion/advice:

    Following xml is used:

    	<button id="rxCalculate"
    							label="Hiring Plan Calculate"
    							imageMso="RecurrenceEdit"
    							size="large"
    							onAction="rxbtnCalculate"
    							getEnabled ="rxCalculate_getEnabled"/>
    Following VBA used:

    'Callback for rxCalculate getEnabled
    Sub rxCalculate_getEnabled(control As IRibbonControl, ByRef returnedVal)
        
    Dim x As Boolean
    Dim Worksheet As Worksheet
    Dim CurrentWb As Workbook
    
    Set CurrentWb = ActiveSheet.Parent
    
    For Each Worksheet In CurrentWb
        If Worksheet.Name = "Wkly. Sum." Then x = True
    Next Worksheet
    
    Select Case x
        
        Case Is = True
            returnedVal = True
        Case Is = False
            returnedVal = False
    End Select
    
    End Sub
    Even if the code is ok, it wont work since there won't be any worksheet when the UI loads(only the application window). How should i proceed? Basically i want a specific ribbon button to be disabled when the current workbook doesnt contain a worksheet named "Wkly. Sum."

    Thanks
    Last edited by Bishonen; 01-09-2013 at 10:16 AM.
    If you think that my answer was helpful, please click on the "Add to this user's Reputation" button.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1