View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] oitbso@yahoo.com is offline
external usenet poster
 
Posts: 18
Default Copy and Paste an HTM file with Vba

On Apr 7, 3:14*am, Gwyndalf
wrote:
I'm fairly new to Vba and have written some code that will open IE and allow
me to navigate to my chosen file. *(I cannot use WebQuery to retrieve the
data as it fails to identify any there.) *Manual Copy and paste does the
trick but I'm seeking to automate the process. *Can anyone advise me how to
instruct IE to 'select all', 'copy' and then paste it into my workbook on the
sheet named 'Hands'.

Sub ListLinks()

* * Dim IeApp As InternetExplorer
* * Dim sURL As String
* * Dim IeDoc As Object
* * Dim MyURL As String
* * ' I need this to be variable/ user defined
* * MyURL = Application.GetOpenFilename()
* * Set IeApp = New InternetExplorer

* * 'Make it visible
* * IeApp.Visible = True

* * 'define the page to open
* * sURL = MyURL

* * 'navigate to the page
* * IeApp.navigate sURL

* * 'Pause the macro using a loop until the
* * 'page is fully loaded
* * Do
* * Loop Until IeApp.readyState = READYSTATE_COMPLETE

* * Code needed here to copy and paste entire web page

* * Worksheets("Hands").Activate
* * Range("A1").Select
* * ActiveSheet.Paste

* * 'Clean up
* * Set IeApp = Nothing

End Sub


Usually, one of the following two constructions would accomplish
this...Ron

ie.ExecWB OLECMDID_SELECTALL, _ OLECMDEXECOPT_DONTPROMPTUSER
ie.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT

or

ie.ExecWB 17, 2
ie.ExecWB 12, 0