+ Reply to Thread
Results 1 to 3 of 3

Adding OLE Objects to Forms

  1. #1
    Registered User
    Join Date
    09-04-2006
    Posts
    29

    Adding OLE Objects to Forms

    This is simialr to my last post where someone showed me how to add OLE Objects to sheets. Now I need to add it to a form.

    I need to dynamically add commandbuttons to a form depending on the number of sheets. ie for each sheet there should be a new command button

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Ben,

    Here is the code to add a command button. Once the Command Button is added, you will need to execute another macro to create the Click event procedure. Otherwise clicking the Command Button will do nothing.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 02-08-2007 at 10:25 PM.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Ben,

    Here is the second part of adding and OLE control to the UserForm, creating an event procedure from code. For this to work, you will have to add a reference to the VB Extensibility library.

    In the VBA editor, go to the "Tools" menu, choose the "References" item, and put a check next to "Microsoft Visual Basic For Applications Extensibility" library. This enables VBA to find the definitions of these objects. If you are using Excel 2000 or later, it will appear with a version number: "Microsoft Visual Basic For Applications Extensibility 5.3". It is very important that you reference the proper library. If you reference the wrong library, you will receive "Type Mismatch" errors. If you don't reference the extensibility library at all, you will receive "User Defined Type Not Defined Error" messages. Click the OK button to load the library.

    Please Login or Register  to view this content.
    A few points about formatting the code that is inserted into the code procedure. It must be a String. If an argument has quotes, like "This is a string." you must use double quotes to enclose it, like this...""This is a string."" A line ends with a Carriage Return Line Feed character, vbCrLf. This is all shown in the code sample above.

    Sincerely,
    Leith Ross

+ 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