Solved

Automation with VB6 and MS Word

Posted on 2008-10-06
5
282 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
ID: 22656942
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
ID: 22660168
I don't see Microsoft Word listed anywhere.  How do I bring it in?
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 22661306
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
ID: 22666418
"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
ID: 22675320
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

685 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