Copy Specific Text From Internet Explorer Window with VBScript
Hello! I am trying to automate a process in which I need to copy and paste specific information from a website. I developed a VB Script that opens up the site (using IE), navigates to the record I need, selects all (using sendkeys), copies the info, then pastes it into a MS Notepad document. However, I only need to grab a few lines from the site. How can I do this? Is it possible to set the range for exactly what I need? For the record, the information will always be in the same location. Is it possible to have the script only select and copy specific characters (line 23, 12 characters in, copy twenty characters)? I should add that I am very new to scripting, so any answers will have to be very explicit. Thanks for the help!
Here is the relevant portion:objShell.SendKeys "^a"WScript.sleep 1000objShell.SendKeys "^c"WScript.sleep 1000objShell.Run "notepad"WScript.sleep 1000objShell.SendKeys "^v"
Shift-3: Thanks for the quick response! That is an awesome script and extremely close to what I am looking for. I ran it and it seemed to pull the requested line and charaters from the html. My problem is, the information I am viewing is a table (it's not static) and is not in the source html code. It is the result of a search (I select a record in the previous page, and it populates the table with the info from that record in the next page). It it possible to pull (copy) the info directly from the screen? I don't have access to the source info.
Another problem I have is that I need to loop through several records. Basically, I have a page with hundreds of records. I need the script to select one record, then pull three fields from that record (on the next page), then go back, go to the next record and do the same...loop for all the records. Ideally, I need to have each set of fields on one line of the .txt file, as opposed to overwriting the file each time. I imagine I would have to save the fields to some sort of buffer or virtual file, then download the info to the .txt file once it looped through all records.
Thanks again for the quick response. I really appreciate it.
matthewlorin7
ASKER
Shift-3: I didn't see it the first time, but the info I need to copy IS in the html (it's burried!). That said, the second half of my problem still applies: I need to loop through many records and then export. Thanks!
Another problem I have is that I need to loop through several records. Basically, I have a page with hundreds of records. I need the script to select one record, then pull three fields from that record (on the next page), then go back, go to the next record and do the same...loop for all the records. Ideally, I need to have each set of fields on one line of the .txt file, as opposed to overwriting the file each time. I imagine I would have to save the fields to some sort of buffer or virtual file, then download the info to the .txt file once it looped through all records.
Thanks again for the quick response. I really appreciate it.