Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2005
    Posts
    144

    Red face Unanswered: A quick Button question

    Hi All,

    I have a button on my excel sheet with a this code behind it. when I click on this button it pops up a window asking and after I input it takes me to an appropriate page.
    The problem I am having is after few seconds later it opens that popup window again. I don't want to have the popup window opening after the first click. In other words it should only open when clicked.

    Private Sub CommandButton1_Click()
    Dim ans As String
    Dim mysite As String

    ans = InputBox("Please enter Part Number?")

    Set IE = CreateObject("InternetExplorer.Application")
    With IE
    .Visible = True

    mysite = "http://www.yahoo.com/WSearch.aspx?Wchar=Y&searchText=" & ans

    .Navigate mysite
    Do Until .ReadyState = 4: DoEvents: Loop

    ans = InputBox("Part Number?")
    If ans = "" Then Exit Sub

    End With

    End Sub

    Any suggestions?

    Thanks

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Difficult to be certain how this is suppose to work, but pehaps this is what you had in mind
    Code:
    Private Sub CommandButton1_Click()
        Dim ans As String
        Dim mysite As String
    
        ans = InputBox("Please enter Part Number?")
        If ans = "" Then Exit Sub
    
        Set IE = CreateObject("InternetExplorer.Application")
        With IE
            .Visible = True
    
            mysite = "http://www.yahoo.com/WSearch.aspx?Wchar=Y&searchText=" & ans
    
            .Navigate mysite
            Do Until .ReadyState = 4
                DoEvents
            Loop
    
        End With
    
    End Sub
    ??

    I also think you should have some data validation on the user input (ans)!!

    MTB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •