Solved

Automation with VB6 and MS Word

Posted on 2008-10-06
5
239 Views
Last Modified: 2013-11-25
Experts,

I'm attempting to embed MS Word in a VB6 form using the attached snippet.  It works, but it opens the Word document outside of the VB app.  How do I make it open up inside the app?
Dim oMSWord As Word.Application

    Dim oWordDoc As Word.Document
 

    Set oMSWord = CreateObject("Word.Application")

    oMSWord.Visible = True

    

    Set oWordDoc = oMSWord.Documents.Open("C:\Documents and Settings\Curt\My Documents\Work\6899 FORM.doc")

Open in new window

0
Comment
Question by:NigelRocks
  • 3
  • 2
5 Comments
 
LVL 14

Assisted Solution

by:rachitkohli
rachitkohli earned 500 total points
Comment Utility
With the above code, you cannot open within your program.
For that you may have to use an OLE component
Try following steps:

1. From the Toolbox, add OLE control onto your form.
2. This will show you the list of application that has to be embedded. Select Microsoft Word.
3. Add the following code on your form load :
OLE1.CreateEmbed "C:\Documents and Settings\Curt\My Documents\Work\6899 FORM.doc"

You may double click the control to edit it..
0
 
LVL 1

Author Comment

by:NigelRocks
Comment Utility
I don't see Microsoft Word listed anywhere.  How do I bring it in?
0
 
LVL 1

Author Comment

by:NigelRocks
Comment Utility
rachitkohli,

From what I can see, I'll have to buy a third party .ocx to do this (and they're very expensive).

0
 
LVL 14

Accepted Solution

by:
rachitkohli earned 500 total points
Comment Utility
"I don't see Microsoft Word listed anywhere.  How do I bring it in?"

Please ensure Microsoft Office is installed on the system & you have Work as well.

Alternatively you can try a free component from Microsoft : DsoFramer
This is a control specifically meant to host Microsoft Office Files i.e. Word, Excel. And its much excellent to use & great supporting features. I have used in .NET. But this is a normal ActiveX component which can be easily used in VB6 as well.
This is the link. Its very easy to integrate
http://support.microsoft.com/kb/311765
0
 
LVL 1

Author Comment

by:NigelRocks
Comment Utility
Actually, it turns out to not be quite what I'm looking for (but useful).  The only other control I've been able to add to my toolbox is Microsoft Word Document.  I haven't seen anything else.  For whatever reason, I haven't had any luck using it.  Maybe I need to just read up on that.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now