+ Reply to Thread
Results 1 to 8 of 8

Run macro from activeX button to module? strange error?

Hybrid View

  1. #1
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Run macro from activeX button to module? strange error?

    Hey

    I cant figure this out. I dont know why i get this error when trying to run a macro of a activeX button in excel 2016.

    I have this code:
    Private Sub Steg1Ext_button_Click()
    Call imghidd
    End Sub
    Then i have this code
    Sub imghidd()
    extinstr1_label.Visible = True
    End Sub
    I have tried to remove "call" but it still does not work.

    Anyone able to help me run a macro from a module?

    This is the error i get.
    http://prntscr.com/nev9u3 (screenshot)
    variable not defined

    But why should i define a variable, all i want is to hide or unhide a control.

    How should i type this code.
    Not been able to find any solution yet.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Run macro from activeX button to module? strange error?

    And what's up if you put the code (imghidd) in the sheet's code not in a module
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Re: Run macro from activeX button to module? strange error?

    The code works if i put it in the sheet´s code and not the module.
    But i want the code to run from the module and not the sheet´s

    How can i make this happen?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Run macro from activeX button to module? strange error?

    Quote Originally Posted by behedwin View Post
    The code works if i put it in the sheet´s code and not the module.
    But i want the code to run from the module and not the sheet´s
    Prefix with the codename of the sheet, e.g.,

    Sheet1.extinstr1_label.Visible = True
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Run macro from activeX button to module? strange error?

    Reviewing the error message it is pointing out a variable not define ...!
    Which statement is higtlighted ?
    Where is the label extinstr1_label ?

    Can you attached an Excel sample file ?

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Run macro from activeX button to module? strange error?

    See next code where the sheet's name is mentioned

    Sub imghidd1()
        Sheets("Test").extinstr1_label.Visible = False
        Sheets("Test").extinstr1_label.Visible = True
    End Sub

  7. #7
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Re: Run macro from activeX button to module? strange error?

    Quote Originally Posted by PCI View Post
    See next code where the sheet's name is mentioned

    Sub imghidd1()
        Sheets("Test").extinstr1_label.Visible = False
        Sheets("Test").extinstr1_label.Visible = True
    End Sub
    Perfect, this worked!!

  8. #8
    Registered User
    Join Date
    12-03-2014
    Location
    swe
    MS-Off Ver
    office 2010
    Posts
    57

    Re: Run macro from activeX button to module? strange error?

    I have setup an example excel and for some reason that code work.

    it reacts on sheet1 with the same error
    Sheet1.extinstr1_label.Visible = True

    but i have tried sheet1-sheet10.
    can i define my sheet some other way?

    the file i need to build this is in, is quite old. maybe someone have created 100 sheets and i should have sheet35 instead... i dont know

+ 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. ActiveX Command Button combined with ActiveX List Boxes – VBA Code Needed
    By Stlcards13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2017, 02:56 PM
  2. Inserting Row Macro using Command Button (ActiveX) relative to Button
    By mebailey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-12-2016, 09:17 PM
  3. Run activex command button via macro
    By dhaval123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2013, 06:07 AM
  4. [SOLVED] ActiveX command button error on Mac!!!
    By devpp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-26-2013, 03:09 AM
  5. Error: Referencing using activex command button
    By ExcelGal in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2012, 01:52 PM
  6. Print Macro / module error & Update / Clear Macro error
    By mal.b.graham in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-28-2012, 06:40 PM
  7. [SOLVED] How do I run a macro with an activex button?
    By geo in forum Excel General
    Replies: 0
    Last Post: 01-17-2006, 07:00 PM

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