Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

How to elegantly embed Word onto VB form?

I need to embed a Word textbox field onto VB form, which will be used to present to user a Word document (formatted text), and if needed, enable changing of the text. I tried to embed Word using the OLE Container Control. The problem is that it is behaving very inelegantly. The user need to double-click the container in order to open container for editing. Then, when editing is initiated, around the container/Word object there is an ugly dark grey rectangle which can be dragged and resized, the purpose of which is not clear to me, but which is a deal breaker…
I would need an elegant textbox filed which can show Word text, and can be edited without any hustle (just as simple as TextBox or RichTextBox). But this textbox field MUST be of the Word type, i.e. able to show a formatted Word text (with ALL formatting of a Word document), and to have the access to the complete Word object model, for instance the text in that textbox field can be manipulated using the Range and Selection objects of the Word. A Word OLE Container Control seams as a natural choice, but its implementation seems extremely clumsy and ugly. Can it be done more elegantly?

PS: I have upload an image, showing what I mean by the "gray rectangle", and also a simple test form...
OLE.png
Test.zip
0
npaun
Asked:
npaun
  • 3
  • 2
  • 2
2 Solutions
 
GrahamSkanCommented:
No.
Hopefully, for your sake, my response of, 'It isn't possible to do what you are asking for' will get an 'Oh yes it is, and this is how', rejoinder, but I very much doubt it.
0
 
Jacques Bourgeois (James Burger)Commented:
Do not put both VB6 and VB.NET in your tags. They do things differently, specially for the interface, so an answer that is good for one is not good for the other.

Since you are talking of a Ole Control, you are probably in VB6. There are controls that can replace the Ole Control, but in order to get something better than the Ole Control, you have to expect a high price: http://www.componentsource.com/relevance/index.html?q=word+control+activex
0
 
npaunAuthor Commented:
Third party ActiveX would probably not be a good solution: besides the price tag, it is likely that it wouldn't have anything of the Word object model, which is necessary, i.e. the Word "textbox" has to be accessible as VBA Word.Application object...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Jacques Bourgeois (James Burger)Commented:
If you need something out of the box, then there are only 3 solutions, the Ole Control is the only way to go.

The alternatives are more limited, and are probably not what you want. Save the document as a rtf file and work with it in a RichTextBox. Or switch to .NET and work on you document as an Add-In or through something such as Aspose (http://download.cnet.com/Aspose-Words-for-NET/3000-10250_4-10289651.html).

You have to understand that anything that displays a Word document, specially if you go outside of standard word processor functions such as your TextBox, you need a very complex component. That is not something that comes free, and it will have limitations.

The Ole Control is able to do it because it uses Word in the background. Anything else would need to recreate a lot of Word's functionality. When you think of the work it would required to build such a thing, and the limited number of potential buyers, you can understand that this is does not attract the interest of many developers. Although I never used it personally, I hear a lot of good things about Aspose, and you can try it for free to see if it suits your needs.
0
 
npaunAuthor Commented:
I probably need to clarify: I HAVE to use Word (in essence), and I suppose by using OLE, which exposes Word object model just as expected and needed; I only need to see if there is a way to get reed of the two nuisance I've mentioned: the need for double-click to edit, and the gray rectangle...
0
 
GrahamSkanCommented:
Why don't you open just open Word from your application and let the user edit the document at will. Note that there are ways of preventing the editing of specific areas of a document.
0
 
Jacques Bourgeois (James Burger)Commented:
You cannot get rid of the grey rectangle. It comes does not come with the Ole Control, it comes with OLE. Link part of an Excel sheet in a Word document, and you will get it event if Word does not user the Ole Control. It is an indication to the user that he is temporarily working inside another application than the one that provides the current window.

As for the need to double-click on it, I remember that it could be done programmatically, but I do not remember how and do not have VB6 anymore to try to figure out how to do it.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now