If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > A quick Button question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-15-11, 16:16
ranjah ranjah is offline
Registered User
 
Join Date: Jul 2005
Posts: 137
Red face 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
Reply With Quote
  #2 (permalink)  
Old 09-20-11, 10:01
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On