+ Reply to Thread
Results 1 to 5 of 5

Adding Code to an Existing UserForm with VBA

  1. #1
    Forum Contributor
    Join Date
    02-14-2007
    Location
    Chester, England
    MS-Off Ver
    2010 & 2016
    Posts
    312

    Adding Code to an Existing UserForm with VBA

    Hello All

    I hope someone can help me.

    Is it possible to add some code to an existing UserFrom with VBA only?

    I have around 50 spreadsheets that are being used by employees to record their work. I have now written a script to make some adjustments to these sheets and update them. The intention is that I will send out a sheet with a macro that will adjust and update their time sheet for them.

    The script now does almost everything I want it to, however I would like to be able to add the following code to an existing UserForm in the workbook called "NewSheet"

    Please Login or Register  to view this content.
    Sorry for the long winded description but I wanted to explain why I want to make this seeming minor change through VBA.

    Thanks in advance for any help you can provide.

    Cheers

    Jim
    Last edited by JimmyA; 04-08-2010 at 09:42 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Adding Code to an Existing UserForm with VBA

    If the forms are all the same, I would create the form in a workbook as you want it, then export it. Then use code to remove the old one from the target workbooks and reimport the new one - see Chip's page here for example.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    02-14-2007
    Location
    Chester, England
    MS-Off Ver
    2010 & 2016
    Posts
    312

    Re: Adding Code to an Existing UserForm with VBA

    Thanks romperstomper

    I have got this to work on my machine with no problems at all.

    The only problem I have come up against now is that the "Trust Access to the VB Project" isn't ticked on the other peoples machines and so the code wont run.

    I think I will have to leave this out of my code as I understand the only way to enable this via VBA is with SendKeys (which I have no understanding of but everyone seems to slag them off) or some sort of registry edit. Both of these sound like a bad idea to me. Are there any other ways of doing this?

    Thanks again for your help romperstomper

    Jim

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Adding Code to an Existing UserForm with VBA

    No, you have to alter the registry (one way or the other).
    You might be better off putting the form and code into an add-in and distributing that to the users. Then you can send out updated versions of the add-in without worrying about the data being lost (since they are separate files).

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Adding Code to an Existing UserForm with VBA

    I would have the form any relevant code in an addin & distribute that
    Hope that helps.

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

    Free DataBaseForm example

+ 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