+ Reply to Thread
Results 1 to 4 of 4

Excel CustomUI Ribbon - Retrieve Variable Value from another Sub ()

Hybrid View

  1. #1
    Registered User
    Join Date
    09-22-2009
    Location
    Yep
    MS-Off Ver
    Excel 365 Pro Plus
    Posts
    34

    Excel CustomUI Ribbon - Retrieve Variable Value from another Sub ()

    Hi There
    I have a macro that use a CustomUI Ribbon with dynamic Dropdown menu (see described below).
    Based on selection, the user should click in a button and run another macro that would open another workbook.

    The value from the dropdown is captured by "returnedVal1" but when I try to use it from Sub Details (), I failed. Value is blank ("")
    Could you please help me and provide the right directions to fix it?
    Another issue is: Is there a way to refresh my CustomUI Ribbon automatically every time I open the file?

    Hope to be hearing from you soon
    Thanks and regards


    Private Sub itemCount(control As IRibbonControl, ByRef returnedVal1)
        Call DropDown1
        returnedVal1 = iItemcount5
    End Sub
    Private Sub getItemLabel3(control As IRibbonControl, index As Integer, ByRef returnedVal1)
        returnedVal1 = vRngValues(index)
    End Sub
    Macro 3)
    Private Sub Details(control As IRibbonControl)
    Dim wsSheet As Worksheet
    Dim sFile$
    
    Set ws1 = ActiveWorkbook.Sheets("Summary")
    
    On Error Resume Next
    
    If returnedVal1 = "File1_Name" Then
        sFile = ActiveWorkbook.Path & "\" & "File1_Name.xls*"
        If Dir(sFile) = Empty Then
            MsgBox "File: " & sFile & vbCr & "...was not found", , "File Doesn't Exist"
            Exit Sub
        Else
            Set wbFile1_Name = Application.Workbooks.Open(ActiveWorkbook.Path & "\" & Dir(sFile))
        End If
    ElseIf returnedVal1 = "File2_Name" Then
        sFile = ActiveWorkbook.Path & "\" & "File2_Name.xls*"
        If Dir(sFile) = Empty Then
            MsgBox "File: " & sFile & vbCr & "...was not found", , "File Doesn't Exist"
            Exit Sub
        Else
            Set wbFile2_Name = Application.Workbooks.Open(ActiveWorkbook.Path & "\" & Dir(sFile))
        End If
    Elseif ...
    
    Endif
    Exit Sub
    Last edited by Mota; 08-11-2017 at 04:58 PM. Reason: Adjust my post to match the rules requirements

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,725

    Re: Excel CustomUI Ribbon - Retrieve Variable Value from another Sub ()

    Apparently you did not read the forum rules when you joined as you have violated two of our very few. Please take the time to review the rules you agreed to and then repair your post to comply.



    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    Cross posted: http://chandoo.org/forum/threads/exc...her-sub.35436/

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Excel CustomUI Ribbon - Retrieve Variable Value from another Sub ()

    Hi,

    You should use another variable, appropriately scoped, to store the label value when changed. It will need to be declared at module level and possibly Public depending on your code location.

    I'm not sure what exactly the second issue is. Typically you must invalidate the ribbon or specific controls if you alter them.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Registered User
    Join Date
    09-22-2009
    Location
    Yep
    MS-Off Ver
    Excel 365 Pro Plus
    Posts
    34

    Re: Excel CustomUI Ribbon - Retrieve Variable Value from another Sub ()

    Hi
    I made it public and worked.
    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. variable formula to retrieve unique values from multiple criteria
    By deanusa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-22-2016, 05:13 PM
  2. Import CustomUI/Ribbon at Opening Excel
    By Dubrock in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-25-2015, 05:00 AM
  3. Excel 2013 Issue with CustomUi Onload
    By nicholas.phillips in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2014, 03:22 AM
  4. How to make appear TAB created using CustomUI editor in all excel
    By Amit112009 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-19-2014, 10:12 PM
  5. Replies: 3
    Last Post: 01-13-2014, 12:46 PM
  6. [SOLVED] Resetting the CustomUI Ribbon Checkbox back to Unchecked
    By BuckoAk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2012, 05:42 AM
  7. customUI Commands
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2009, 02:52 AM

Tags for this Thread

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