+ Reply to Thread
Results 1 to 5 of 5

Running VB in Excel on loading document

  1. #1
    Registered User
    Join Date
    04-25-2008
    Posts
    49

    Running VB in Excel on loading document

    Hi

    This is an Excel/VB novice question.

    I've done a little VB4 programming quit a few years ago. These were of course stand alone compiled projects. However I've never created and used VB forms in Excel and would like to know how to run VB from opening an Excel worksheet

    I have created a form with appropriate buttons and text windows. I save it but when I load the spreadsheet I have to select tools, macro, VB editor to load and run it. I there a way it will autorun or can it only be done from a macro / CTRL key combination after loading.

    Sorry if the question seems dumb but I can't get my VB help to work properly despite trying to re-install from the original Office 2003 **

    Regards
    Martin

  2. #2
    Registered User
    Join Date
    07-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Running VB in Excel on loading document

    If you go into the Visual Basic Editor you should see in the VBA project window an option called ThisWorkbook.

    In this you can place the following code :

    Please Login or Register  to view this content.
    Just put in the name of your form

  3. #3
    Registered User
    Join Date
    04-25-2008
    Posts
    49

    Re: Running VB in Excel on loading document

    Hi Conrad

    Thanks for the info but still can't get it to work, I'm sure I'm doing something stupid.

    I have a form called Survey with a single button and text box. I have put the following code in VBA Project, ThisWorkbook. I then saved the file and reloaded a blank worksheet. Any ideas?

    Private Sub Workbook_Open()
    Call Load(Survey)
    End Sub

    Regards
    Martin

  4. #4
    Registered User
    Join Date
    07-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Running VB in Excel on loading document

    Try this

    Please Login or Register  to view this content.
    I assumed that you had an initialize macro in the form to show it.

  5. #5
    Registered User
    Join Date
    04-25-2008
    Posts
    49

    Re: Running VB in Excel on loading document

    Perfect, Thanks for you help.

    Best Regards
    Martin

+ 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