?
Solved

copy exact content of webpage in word via visual basic

Posted on 2007-09-28
2
Medium Priority
?
258 Views
Last Modified: 2010-04-30
Hi,

I am creating a Visual Basic 6 app that needs to take the content of a webpage (including images, formatting, etc.) and copy it into a Word file.

I thought about two ways of doing this:
1)Open an instance of IE via Visual Basic, do a "Select All - Copy", then paste the clipboard in Word
2)Save the webpage as mht and open it in Word (is there a component that lets me save a url as if I opened Explorer and did "Save As Mht file"?)

Can you guys show me how to accomplish any of these two strategies?

Thanks.
0
Comment
Question by:Vido81
  • 2
2 Comments
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 19977723
Use WebControls activex using Microsoft Internet controls and then get the data to copy in clipboard and then get to winword.
0
 
LVL 23

Accepted Solution

by:
Ashish Patel earned 2000 total points
ID: 19977733
Or use the following to get the output of the webpage by the following. May be this function can be usefull to you.

Option Explicit

Public Function GetSource(ByVal Url As String, ByVal TargetFilePath As String) As String
    Dim Obj
    Set Obj = CreateObject("MSXML2.ServerXMLHTTP")
   
    Dim Status As Variant
    Status = "Nothing"
   
    Obj.Open "GET", Url
    Obj.send
   
    If Not Obj.Status = 200 Then
        Status = "Error Occurred : " & Obj.Status & " - " & Obj.statusText
        GetSource= "false"
    Else
        Open TargetFilePath For Output As #1
        Print #1, Obj.responseText
        Close #1
       
        Status = "File Created As :" & TargetFilePath
        GetSource= "true"
    End If
   
    Set Obj = Nothing
End Function

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month8 days, 17 hours left to enroll

621 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