+ Reply to Thread
Results 1 to 5 of 5

How to call userform/sub in Addin from worksheet event

  1. #1
    Registered User
    Join Date
    08-16-2007
    Location
    Portsmouth, UK
    Posts
    86

    How to call userform/sub in Addin from worksheet event

    My program which is an addin creates a new worksheet in a workbook. I would like that sheet to be protected so that no data on it can be edited but that double clicking on a cell will displace a userform that is contained within the .xla file.

    I can get the prgram to write code to the newly created worksheet (http://www.excelforum.com/showthread.php?t=619171) but have realised a problem. The workbook containing the sheet is a seperate file to the .xla file and therefore if I try and call a sub or ther suerform from the worksheet it is not recognised.

    Is there a way to reference procedures in an addin from any workbook?

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this, change File.xla to the name of your addin. Make sure that any code in the userform refers to the correct workbook, ActiveWorkbook or Thisworkbook(the addin)
    in the workbook:
    Please Login or Register  to view this content.
    in the addin
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    08-16-2007
    Location
    Portsmouth, UK
    Posts
    86
    Hi, sorry for the slow reply, have been on holiday,

    I am using the following code, but keep getting the error that the macro can not be found, Is this because there are spaces in the title of the xla file?

    Please Login or Register  to view this content.
    The sub that calls the form is called ShowForm

  4. #4
    Registered User
    Join Date
    08-16-2007
    Location
    Portsmouth, UK
    Posts
    86
    Additional information: the project contains two modules, the sub is in a module called "GetGroups" Do I have to reference the module name in order of the program to locate the sub and if so how?

  5. #5
    Registered User
    Join Date
    08-16-2007
    Location
    Portsmouth, UK
    Posts
    86
    It was due to the spaces in the name, so now have the code to call the form working, thanks Roy

+ Reply to Thread

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