Solved

Code example of V5 and Word 97 Integration

Posted on 1998-04-26
5
220 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
5 Comments
 
LVL 1

Expert Comment

by:chdy
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Bought This Question.
0
 
LVL 9

Expert Comment

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
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…
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 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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now