+ Reply to Thread
Results 1 to 16 of 16

Where is the main user form called from?

  1. #1
    Forum Contributor
    Join Date
    10-12-2018
    Location
    Leesburg, FL
    MS-Off Ver
    2013
    Posts
    113

    Where is the main user form called from?

    If I create a new form from scratch, where is the MainForm.Show being called from? In other words, when I hit F5, where is this happening?

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,238

    Re: Where is the main user form called from?

    Within the executable code of the VB run time.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    10-12-2018
    Location
    Leesburg, FL
    MS-Off Ver
    2013
    Posts
    113

    Re: Where is the main user form called from?

    Quote Originally Posted by rorya View Post
    Within the executable code of the VB run time.
    Is that something that is accessible?

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Where is the main user form called from?

    Userforms are Application objects, just like ThisWorkbook, Sheet1, Sheet2, Module1, etc. When you execute the UserForm.Show command, the application looks for that object in the Pruject list. If you open the vb editor (Alt + F11) you can see the Project list in the upper left corner of the editor window. If a userform of the name specified exists in the Project list, it will become visible on the screen. You can get more detailed information by doing a web search on 'Excel UserForms'.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,238

    Re: Where is the main user form called from?

    Quote Originally Posted by bvwalker1 View Post
    Is that something that is accessible?
    No. Why would you need to?

  6. #6
    Forum Contributor
    Join Date
    10-12-2018
    Location
    Leesburg, FL
    MS-Off Ver
    2013
    Posts
    113

    Re: Where is the main user form called from?

    Quote Originally Posted by rorya View Post
    No. Why would you need to?
    I was wanting to use vbModeless with it so that once my form opens and modifies and saves a file, I want to be able to close that file. Currently, I cannot do that while the form is still running even though it has finished what it needed to do.

  7. #7
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Where is the main user form called from?

    The basic userform that you insert to build your custom userform is an application item. That means that it is part of the underlying VBA software which is generally not accessible by the user, since it is proprietary to Microsoft.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,238

    Re: Where is the main user form called from?

    Why are you running your form by selecting and pressing f5? Add a routine that shows it using the Show method, and specify the argument. You can also set the form's ShowModal property to false.

  9. #9
    Forum Contributor
    Join Date
    10-12-2018
    Location
    Leesburg, FL
    MS-Off Ver
    2013
    Posts
    113

    Re: Where is the main user form called from?

    Quote Originally Posted by rorya View Post
    Why are you running your form by selecting and pressing f5? Add a routine that shows it using the Show method, and specify the argument. You can also set the form's ShowModal property to false.
    I'm somewhat new to VBA programming, but not to programming in general. Is there a way to make my form a stand alone executable? For instance, myForm.exe?

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,238

    Re: Where is the main user form called from?

    No, not these days. Why use Excel at all if you want an .exe?

  11. #11
    Forum Contributor
    Join Date
    10-12-2018
    Location
    Leesburg, FL
    MS-Off Ver
    2013
    Posts
    113

    Re: Where is the main user form called from?

    Quote Originally Posted by rorya View Post
    No, not these days. Why use Excel at all if you want an .exe?
    Because that is all I have to work with at work.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,238

    Re: Where is the main user form called from?

    Then you are out of luck on that front. You could make its containing workbook into an add-in. I can't say if that would help without knowing why you want it to be an executable.

  13. #13
    Registered User
    Join Date
    01-09-2019
    Location
    nottingham
    MS-Off Ver
    office 16
    Posts
    9

    Re: Where is the main user form called from?

    try bat2exe by igor whatshisface - great utility to get a directory with all the goodies you like into exe with a batch script to run what you want from it. but be sure to map the folder to local and copy out of temp, give it unique name

  14. #14
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Where is the main user form called from?

    Put this in a normal code module

    Please Login or Register  to view this content.
    Then you can call the sub (and show the userform) either from the Macro dialog box or assign it to a button.
    Add the modeless argument if that is what you want.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Where is the main user form called from?

    At what point are you opening the file you are going to modify?

    Are you opening it with code run from the userform?

    If you are I can't see why you can't do that, modify the file and then close the file, all using code in the userform module.
    If posting code please use code tags, see here.

  16. #16
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Where is the main user form called from?

    I think that just getting to understand how Excel works might be the best solution. VBA is a powerful tool to use in conjuction with the built in facilities of Excel. But don't rely on Excel for graphics. While Excel has drawing capabilities, it is not a graphics application the graphics it uses are very imprecise. But they are good enough for general use in gussying up your worksheets.

+ 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. [SOLVED] Returning to Main Macro from a Called Procedure after a MsgBox/Exit Sub
    By liquidmettle in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-18-2018, 09:15 AM
  2. Issue Converting Sub to Function to End Main Sub after Called Sub Exits
    By morangeman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-21-2017, 06:00 AM
  3. [SOLVED] Calling User form Initialize: A way to display certain tab based on which sub called?
    By emilyloz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2013, 10:06 AM
  4. [SOLVED] User Form to execute search and return all values to the user form for editing
    By allwrighty in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2013, 10:40 PM
  5. Filtering Form Criteria and Searching Main Form
    By gatorator in forum Access Tables & Databases
    Replies: 3
    Last Post: 04-06-2011, 07:48 AM
  6. to exit main procedure from procedure called by yhe main
    By kmlprtsngh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2010, 02:46 PM
  7. Replies: 3
    Last Post: 01-27-2010, 02:28 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