?
Solved

Automation with VB6 and MS Word

Posted on 2008-10-06
5
Medium Priority
?
292 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 2000 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 2000 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

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

770 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