Solved

Automation with VB6 and MS Word

Posted on 2008-10-06
5
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

732 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