Solved

Code example of V5 and Word 97 Integration

Posted on 1998-04-26
5
226 Views
Last Modified: 2010-08-05
I need a source code example of the following:

From VB5 I want to callup Word 97 and create a new document and/or edit an existing document. I am storing the document in a data base file so I want to pass the document to Word using the VB5 program. When the user clicks on save in Word I want to have Word send the document to the VB5 program. In other words I need to override the Word 97 FileSave function.

Lastly, I want to do all the programming in VB5 not (VBA within Word 97) and not by using Macros.
0
Comment
Question by:dougc
[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
5 Comments
 
LVL 1

Expert Comment

by:chdy
ID: 1429892
Option Explicit
Dim PicFile, SaveFile As String
Dim WordBasic As Object
Const OLEAutoWord As String = "word.basic"

Private Sub cmdPic_Click()

dlgOPen.DialogTitle = "Picture Load"
dlgOPen.Filter = "bmp Picture(*.bmp)|*.bmp"
dlgOPen.Action = 1

PicFile = dlgOPen.filename
imgPic.Picture = LoadPicture(PicFile)

End Sub

Private Sub cmdWord_Click()

dlgOPen.DialogTitle = "Document Save"
dlgOPen.Filter = "Document Save(*.doc)|*.doc"
dlgOPen.Action = 2

SaveFile = dlgOPen.filename

If SaveFile = "" Then
  Exit Sub
End If

Set WordBasic = CreateObject(OLEAutoWord)

'word execution display

If chkWord.Value = 1 Then
   WordBasic.Appshow
End If

  With WordBasic
       .filenewdefault
       .startofdocument
       .Bold
       .Underline
       .Insert "Sample"
       .Insert vbCrLf
       .insertpicture PicFile
       .Insert vbCrLf
       .Insert Text1.Text
       .filesaveas SaveFile
  End With
 
  Set WordBasic = Nothing
 
End Sub

'This  is sample program.
   Good Luck
0
 

Author Comment

by:dougc
ID: 1429893
Thank you for your answer chdy but we are looking to open Word with a document we provide, let Word take over for a while while the document is edited and then when we click "Save" in word, somehow communicate that to our VB application and allow our application to handle the saving process. When we tried your code example it worked good except once word was started it seemed to be detached from our VB app. We had no control of what Word was doing at the point when we were ready to save the document.
0
 
LVL 9

Accepted Solution

by:
Dalin earned 400 total points
ID: 1429894
douge,
Try to use an OLE control in your VB form, bound to a data control, with the database field being a OLE MSWord Document.
You can set the size of the OLE container. When you need to edit the word document, just click on the OLE, when you finish, you just neeed to click elsewhere in the vb form. and the nice thing is, when you move your records, the word document field will give you the proper document.  
If you have questions or need further help, let me know.
Regards
Dalin
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1429895
Bought This Question.
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1429896
I did not understand what you mean, Mirkwood. Could you explain a little ?
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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 …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

696 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