Embed Word in a form?

infidel

Member
Joined
Jul 21, 2006
Messages
15
Location
Philadelphia
Programming Experience
10+
I looked around for a similar topic but had no luck finding one.

I have an application where the user needs to be able to edit a small piece of text (a bibliographic citation) in a Winform. They have to be able to do some simple formatting, specifically they have to be able to add bold, italic, superscript, subscript, underline and small caps in any combination (i.e., a small cap could be bolded.)

I tried the RTF box, but it doesn't seem to have subscript, superscript, or small caps. Plus what it does have is too intertwined. If I set the selection to bold and it already had some italic in it, you lose the italic. Word would do perfectly, but I'm not sure how to embed it. I really don't want to launch Word.

I have searched the net and found pieces of what I want, but not the whole thing. Basically I'd have a "text box" on my form that really has a piece of a Word document behind it. The user can type and/or use buttons (either from Word or I could put a toolbar on the form that does it) to format (select a piece of text, hit B button, text is bolded).

The advice I'm finding seems to be load the Word doc in a WebBrowser, which I got to work. (I'd also want to lose the Word toolbars, ruler, status bar, etc. which seem to appear by default and have a plain "text" box, but I'm guessing I can do that with an appropriate Word template later.)

I know how to automate Word as an external app, but I guess the problem is that I don't know how to get a hold of the Word.Application.Document that is loaded in the WebBrowser control. In pseudocode, something like:

Dim oWordDoc as Word.Application.Document
oWordDoc = WebBrowser1.EmbeddedObject
oWordDoc.ActiveWindow.Selection.Bold = True

is sort of what I'm looking for.

Can anyone make any sense of what I'm saying and maybe even have an answer? :eek:
 
Back
Top