Solved

Automation with VB6 and MS Word

Posted on 2008-10-06
5
288 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

724 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