Results 1 to 7 of 7

Thread: Copy contents of Browser Control to Microsoft Word

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    5

    Question Copy contents of Browser Control to Microsoft Word

    Hello,

    In a VB.NET windows application, I am attempting to copy the contents of an AxBrowswer window to a word.application document. Does anyone know how to do this?

    I have the following, but it doesn't work:

    wrdApp2 = CreateObject("Word.Application")

    wrdApp2.Documents.Open("C:\Test1.doc")
    AxWebBrowser1.Select()
    Clipboard.SetDataObject(AxWebBrowser1)

    wrdApp2.Documents.paste(Clipboard.GetDataObject)
    wrdApp2.Documents.Save()

    Overall
    I am able to copy one word document to another and open a word document in a WebBrowser for editing. Know I need to know how to copy the contents of a browser to a word document. My ultimate goal is to put xml data tables into MS Word (not supported in Office 2000 without building some sort of parser).
    Scenario is:
    1. User enters data into Dataset. (Complete)
    2. Program Saves as xml. (Complete)
    3. Opening in web browser using html + xsl style. (Complete)
    4. copy to microsoft word document. (I'm stuck)

    Thanks for all your help.


  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You should ask VB.NET questions , in VB.NET Forum not VB6 Forum .

  3. #3
    Addicted Member Lee_S's Avatar
    Join Date
    Dec 2000
    Location
    New Zealand
    Posts
    250
    VB Code:
    1. 'Try something like this?
    2. wrdApp2.Selection.Paste
    Other than that I don't know
    Lee Saunders
    Win XP Professional : VB6 Enterprise / VB 2005 Express

    History admires the wise, but it elevates the brave.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    5

    Select and Copy contents of axbrowser control (Ctrl+A, then Ctrl+C)

    Thanks Lee. I think you got me one step closer. I was able to paste the contents of the clipboard using your command.

    Now all I need to know is how to Copy the contents from the web browser control such that it is in a format that can be pasted into word. Currently the format I copy from the WebBrowser is not valid for wrdapp.selection.paste. (Either that, or I am not copying the value at all).

    Essentially, now I just need to perform a select all (CTRL+A) and then copy (CTRL+C).

    Anyone that can help would be greatly appreciated!

  5. #5
    Addicted Member Lee_S's Avatar
    Join Date
    Dec 2000
    Location
    New Zealand
    Posts
    250
    Try playing around with this, see if it does what you need. It should copy everything to the clipboard ready for pasting into word.
    VB Code:
    1. ' select all from webbrowser
    2. WebBrowser1.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
    3. ' copy the text to Clipboard
    4. WebBrowser1.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DONTPROMPTUSER
    5. ' clear the selection
    6. WebBrowser1.ExecWB OLECMDID_CLEARSELECTION, OLECMDEXECOPT_DONTPROMPTUSER
    Lee Saunders
    Win XP Professional : VB6 Enterprise / VB 2005 Express

    History admires the wise, but it elevates the brave.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    5
    That worked great!

    Thanks for all your help!

  7. #7
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539
    Do you want to take a screen shot of the entire web document ? Is this what your trying to do....?
    I am curretly building a defect management system for software and web developers,
    If you wana try it out (beta test) and keep it for free just send me a message

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width