Solved

VB6 Classic - Webbrowser double click

Posted on 2015-01-16
5
81 Views
Last Modified: 2015-02-13
Hi

Yes, still using Classic :-)

Would anyone have some code that shows how to double click text on a Web page and then throw it to the Clipboard, based on certain criteria? In my case, I need to allow thi scenario only when the text matches four letters and seven numbers I.e ABCD1234567.

Thanks.
0
Comment
Question by:tvtech
  • 2
5 Comments
 
LVL 20

Expert Comment

by:ltlbearand3
ID: 40554707
Can you use one of the browser objects to open the page and extra the data from the HTML source that way?  Maybe something like one of these:

When you say click on text, is the text a hyperlink and you want the value that comes from the link?

Dim objHttp, objXMLDoc

Set objHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
Set objXMLDoc = CreateObject("Msxml2.DOMDocument") 

With objHttp
	.Open "GET", "http://www.yoursite.com"
	.Send
	objXMLDoc.LoadXML .responseText
End With

msgbox objXMLDoc.SelectSingleNode("//YourNodeName").text

set objHttp = nothing
set objXMLDoc = nothing

Open in new window


Sub GetWebTitle()
	' Need References set to 
      ' MICROSOFT INTERNET CONTROLS
      ' MICROSOFT HTML OBJECT LIBRARY

    Dim objHTML As HTMLDocument
    Dim objTitleElem As IHTMLElementCollection
    Dim objIE As InternetExplorer
    
    Set objIE = New InternetExplorer
    
    With objIE
        ' Enter in the website here
        .navigate "http://www.experts-exchange.com/"
        
        ' Don't show IE as we open it
        .Visible = False
        
        ' Pause while IE Loads
        Do While .Busy Or .readyState <> READYSTATE_COMPLETE
            DoEvents
        Loop
        
        ' Load the web page into an HTML Document
        Set objHTML = .document
    End With
    
    ' Look for the all instances of the tag
    Set objTitleElem = objHTML.getElementsByTagName("Title")
    
    
    ' Put the value from the first instance in cell A1
    Range("A1").Value = objTitleElem.Item(0).outerText
    
End Sub

Open in new window

0
 

Author Comment

by:tvtech
ID: 40555763
Thanks for your comment.

The text is not hyperlinked. Just plain text.
0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 500 total points
ID: 40555840
Since it is plan text, I suggest looking at one of the methods I posted.  You could always do a view source from the web page to see how the data is stored and then use one of the examples posted to help parse the data.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40607543
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question