devxlogo

Copy the contents of the WebBrowser control to the Clipboard

Copy the contents of the WebBrowser control to the Clipboard

To programmatically copy text from the WebBrowser control you can use its ExecWB method, to which you must pass the OLECMDID_COPY constant as its first argument.

WebBrowser1.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT

You can also select the entire WebBrowser’s contents by invoking the ExecWB method with the OLECMDID_SELECTALL constant. For example, you can quickly copy the textual contents of the WebBrowser control (that is, plain text instead of HTML text) with the following statements:

' select the entire documentWebBrowser1.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT' copy the text to ClipboardWebBrowser1.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT' clear the selectionWebBrowser1.ExecWB OLECMDID_CLEARSELECTION, OLECMDEXECOPT_DONTPROMPTUSER

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist