+ Reply to Thread
Results 1 to 3 of 3

Registering button Click on Non-Modal Userform to continue with code

Hybrid View

killpaddy Registering button Click on... 08-19-2014, 11:05 AM
Norie Re: Registering button Click... 08-19-2014, 11:20 AM
killpaddy Re: Registering button Click... 08-21-2014, 07:28 AM
  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    Leeds, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Registering button Click on Non-Modal Userform to continue with code

    Hi,

    I am attempting to fill in an online form in internet explorer, my code fills in the blank input text boxes on the form and then I would like a userform ('DWGRegCheck_Submit') to appear prompting the user to select options from the dropdown menu (hence the userform is non-modal) as it has proven too much of a hassle to achieve this through code. Once selecting the options the user should then be able to click a CommandButton (named 'DWGSubmit_Button') on the userform, and the code will continue and click 'submit' on the webpage etc. etc.

    Heres my attempt so far:

    IN DWGRegCheck_Submit (Code):

    
    Private Sub Cancel_Button_Click()
    
    CancelClick = True
    
    End Sub
    
    Sub DWGSubmit_Button_Click()
    
    DWGSubClick = True
    
    End Sub

    IN Module 1:

    Public DWGSubClick As Boolean
    Public CancelClick As Boolean
    
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Private Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    
    Sub FillInForm()
    Set ie = CreateObject("InternetExplorer.application")
        ie.Visible = True                                       
        SetParent ie.hwnd, Application.hwnd
        ie.navigate (URL)
    
        'fill in text boxes online
    
        DWGRegCheck_Submit.Show
        Do Until DWGSubClick = True                 'This loop code causes excel to crash and the 'click' does not seem to register on the CommandButton
            If CancelClick = True Then GoTo 1
        Loop
        DWGSubClick = False
        DWGRegCheck_Submit.Hide
        
        'further code
    
    1
    End Sub
    The problem I have is when I run the code excel crashes on the Do loop (However it cycles through when pressing F8)

    The 'DWGSubmit_Button' and 'Cancel_Button' do not seem to fire properly as I have left a breakpoint on the lines 'DWGSubClick = True' and 'CancelClick = True' and the code does not pause there

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

    Re: Registering button Click on Non-Modal Userform to continue with code

    Why don't you run this code from a button on the form?

    Then have another button on the form to continue after the user has made their selections.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-01-2012
    Location
    Leeds, England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Registering button Click on Non-Modal Userform to continue with code

    That is my question, how do you code a button on a form that 'continues' with the code?

    I should also note that there is a for loop in the code as is show below, so the procedure is repeated several times.

        'variables defined for datatypes
    
        For datatype 1 to 4
        
        ie.navigate (URL)      'opens page ('refreshes' page to fill in new info on each loop)
    
        'fill in text boxes online specific to datatype
    
        DWGRegCheck_Submit.Show
        Do Until DWGSubClick = True                 'This loop code causes excel to crash and the 'click' does not seem to register on the CommandButton
            If CancelClick = True Then GoTo 1
        Loop
        DWGSubClick = False
        DWGRegCheck_Submit.Hide
        
        'further code
    
        Next

+ 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] Click of button in userform to continue started macro
    By Mimoa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-24-2016, 09:16 AM
  2. VBA to click on 'Continue' button on webpage
    By Jimbo77 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-20-2014, 06:49 PM
  3. Code a Command Button on UserForm not to close upon click - Excel VBA
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-14-2012, 02:20 PM
  4. Userform - Continue and cancel command buttons code
    By Jessica.Bush in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2010, 04:42 PM
  5. Keep Modal UserForm Alive after closing 2nd userform using 2007?
    By ShredDude in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2008, 03:12 PM

Tags for this Thread

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