Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB and MS Word

Status
Not open for further replies.

dirksm

Programmer
Mar 14, 2002
22
0
0
GB
Can anybody give some advise on how to diplay(open as read-only) and edit(open for read and write) a MS Word document in a VB application without actually opening Word?
The user should be able to open an existing document or create a new one.

Any help on which components to use, what the code should look like, etc. would be greatly appreciated.

Thanx!
 
"...without actually opening Word" ?
You have some Work cut out for yourself if you want to give the user the ability to create and edit a Word doc, and save it in Word format, with who knows what type of functionality the interface should offer....
And you can only do this effectively with the Word Object Library. Which means the Client has to has a licensed version of MS Word on their PC (licensed to the PC/User).

So if Word has to be on the client anyways, then use it.

Using a OLE container in your VB Project, you can let the user do this (open/edit/create/save a Word Doc) right with-in your application. It will make your application look and feel just as if it has its own Word processor - but it is really the Word inteface. You can also offer the choice to actually open the document with Word when using the container.

Place the container on a form, and select "create new" and then select MS Word Document. You will need to create a menu item in order to close the container via menu, but the rest is already there for you.
And then you can use the Word Object library to create a Doc, or what ever, and link it to the OLE container at run time.
Play with it, and if this is what you are looking for, then go to MSDN and search for the help files on using the control.

 
I have been using the OLE container, however I find that sometimes when I click on it, it adds the Word menu options to my app(which is what I want), but other times it opens Word itself in a seperate window(which I don't want). Any idea what I'm doing to cause this?

You say I must add an menu option to close the OLE container. Should I only add the OLE.Close method to this option, and what does this do, as I can see no difference? (I've linked a document to the OLE and it displays, but calling the Close method does'nt seem to do anything).

The third problem I have is that I don't know have to link the document to the OLE. I've tried changing the sourcedoc property but that doesn't seem to work.

Could you perhaps supply me with some sample code?

Thanx for all the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top