I need to retrieve only selected portion of a webpage (user open a webpage in web-browser control, then he/she would select some portion of a webpage, i just need only those selected portion/text) in vb.net in visual basic language. How to do ?
i am using microsoft visual studio 2008
Language: Visual Basic
FrameWork: vb.net 3.5
Perhaps here are some answers for you(first post attachment):
Manipulate/Change/Form Fill data in webpages using the Webbrowser control
In terms of IE's API, you can get the select text by getting the selection object via IHTMLDocument2::Selection the property, then create a range object via IHTMLSelectionObject::createRange. If the return range's type property is "Text", you can then query IHTMLTxtRange from it and get the selected text via IHTMLTxtRange::text.
It is unclear which webbrowser control you are referring to. There are 3 webbrowser controls in the .Net Framework, one in Windows Forms, one in WPF, and one in Silverlight. Anyway, you can call InvokeScript or use the unmanaged interface like csexwb's GetSelectedText, if one of the method is supported by your control library.
Next time mention which control library you are using when you ask the question. Merely mentioning the language you choose isn't enough to resolve the ambiguity in class names.
Related
How can I return a message box with functioning HTML tags using VBA?
example
dim mtext as string
mtext = "<em>hello</em> <br> world"
msgbox mtext
You don't. The MsgBox function is just a thin wrapper over a Win32 API function, and that function doesn't deal with HTML input. HTML is for web browsers, not desktop applications.
The closest thing you could get is a custom UserForm with a RichTextBox control, but that's OCX tech developped for Visual Basic 6.0 and probably won't work on x64 machines, not to mention that it will definitely break down if you need to distribute your macro to users that don't have the OCX on their machines.
A better alternative could be to make a COM-visible class library in your favorite .NET language (C#, VB.NET), and expose a custom MessageBox function that displays a WinForms dialog featuring a System.Windows.Forms.RichTextBox control that can process and display RTF formatted text.
You then need to distribute and register your COM type library to your users.
In other words, it can be done - it only depends how badly you want it.
I would custom design a form and then have the text set based on your needs specifically. May I ask why you are wanting to use HTML codes? Cause, it may be simple enough to create your own library/class to handle the processing, before pushing to a rich text box. However, the Rich Text Box is only going to be in VB, like using VB Studio Express. With VBA, you're sort of stuck...sorry.
I am rewriting C++ Outlook Addin application to it full .NET representation using VSTO (Outlook 2007/2010).
One of the features to rewrite is html forms rendering. User can select checkbox, provide input, select option etc. in compose mail mode (before sending). But when I put any input markup to HTMLBody property it isn't rendered as expected. Instead only something like http://postimage.org/image/jk9swfr2t/ is rendered. I spent a very long time to search for a solution but it always ultimately turned out to be impossible due to Word based Outlook HTML render engine.
Our C++ addin code repository is extremely large and is legacy - I am not a c++ developer and don't know to much about COM and c++ outlook corresponding APIs, the target is to rewrite according to existing functionalities, there is simply no time and no resources to analize legacy code.
But the most interesting to me is that c++ version of software render everything: inputs, checkbox, select option, just everything! So I guessed it is possible and started looking for a workaround or any kind of hack.
I analyzed the old c++ addin using OutlookSpy tool and it turned out that it doesn't fill HTMLBody. I had to wade through a partial legacy code and found that it set PR_HTML MAPI property. Unfortunately I found also that this property is not available in vsto so I can't check if it helps.
So my questions are:
do you know any hacks to render HTML forms in Outlook using VSTO?
are there any differences using item.HTMLBody or PR_HTML MAPI property which can have impact on my problem?
if yes then can I set PR_HTML using C#? (I've checked free http://www.add-in-express.com/creating-addins-blog/2008/11/21/outlook-object-model-propertyaccessor-storageitem/ but it doesn't work for me - code doesn't execute when I add AddExpress.MAPI.dll)
Everything must be done programmatically so inserting using Outlook UI or exporting to Outlook from IE doesn't count. Also we can't use commercial third party tools like Redemption or Add-in Express.
Are you sure you posted the right picture? :-)
Keep in mind that Outlook uses Word to render HTML, so any input controls and scripts will not run.
I am in the process of developing an ActiveX control for embedding in Rockwell Automation's Factory Talk View. (See ActiveX DLL Error: Solved to see how great a start I got off to!)
At the moment I have an ActiveX control that seems to embed into the host system OK, but is not fully integrated into the VBA process. I believe that this is because I have not implemented some specific COM interface that is required, but I have no documentation as to what that is. I do know that standard MS controls like the Microsoft Forms 2.0 controls do implement the required interface and fully integrate.
The key functionality I am missing relates to a property that I need to set in order for my VBA code to actually see the ActiveX object. This property can be seen when opening the property panel for any activeX control placed on a Factory Talk screen, but NOT when looking at the properties of ActiveX controls embedded in (for example) Excel. Thus I am probably trying to chase down some custom Rockwell implementation. I am hoping that SO might be able to give me some aid into how to track down what I want based on recognizing the functionality it implements.
Now to the actual property. In Factory Talk the property is called "ExposeToVBA", and has a type "long". You have a choice of 3 values selected from a drop down list:
Not Exposed - When set to this, the controls name is not even visible to VBA code
Type Info Extension - Not sure what this does
VBA Control - VBA code can see and interact with the control.
When I select anything other than "Not Exposed" for my control, I get a warning dialog box with no text on it. For other controls I need to set it to "VBA Control" in order to interact with it in the VBA code (d'oh)
I suspect that the value of this property is translated into some calls to an ActiveX interface on the target control.
The Question
What I want to do is identify what interfaces something like a "Forms 2.0 Label" implements that would match the above functionality. And also perhaps how I could translate this into my C# based control (based on C# ActiveX control (CSActiveX))
I know its a long shot, but I'd appreciate any and all suggestions
This became moot when I found a canned Active-x control that had the functionality that I needed.
FWIW This is what I believe that I used: DMGraph
I have a user control in vb.net application.
and i have a form in vb 6.
so in my vb.net applciation to this user control i need to mention the vb 6 form as its parent.
Means when i run a vb6 application i should see this user control as a part of that form.
Ahy help appreciated.
Take a look at the COM interop Toolkit.
It allows you to easily create com-visible .NET usercontrols, which can be used in VB6 for instance.
You can try saving it as a dom object in .net
After this, you can open it in vb6 in the menu components.
I've done it with guid class of .net but i donĀ“t know what you and to do, but i think you should try it.
It is actually fairly easy to add some plumbing to a VB.NET User control to expose it via COM as an ActiveX control that can be used by VB6 and other COM clients.
Here is an article describing how to do that:
"Writing an ActiveX Control in VB.NET"
I'm a noob to VB.NET and I was wondering how to make something you type into a textbox on the application type that text into a website textbox and submit whats in the textbox by pressing a button? I am using visual studio 2008.
That is a little tricky to do, but it is possible. However, without more details on the specific browser or what you are trying to copy over, you aren't going to get a lot of answers on here.
Better Suggestion: Have you considered instead of trying to control the browser via "voodoo", that you might just have your VB.NET application submit the form/request directly to the web server and cut out the middle-man (the browser)?
I'm assuming you're trying to POST data to a web form from some other application. Check this out; it's in C# but you can translate it to VB.NET. It uses a WebBrowser control and the SetAttribute method to set input values on the web form.
// C#
WebBrowser browser;
...
browser.Document.GetElementById("username").SetAttribute("value", "MyUsername");
...
form.InvokeMember("submit");