Word Merge

tinabee

Registered User.
Local time
Today, 10:51
Joined
Jan 31, 2012
Messages
15
Hello I have a database to track work orders. Each workorder has one part#. Each part# has a 2 page inspection report page created in Word. (1 page for the workorder info (CustomerID, Serial# etc along with other info that does not come from Access and the other page is a drawing). I would like to have a command button on the form to open the word document for the part and merge the WO info. I created a table with 2 fields (InspectionReportID and InspectionReportPath) and a field in the Parts table with the InspectionReportID for the inspection report for the part. I can get the specific report to open but I do not know how to merge the fields with the WOinfo. The code I have on the command button to open the word document is
DoCmd.SetWarnings False

Dim C20GBCOV As String
Dim OpenWord As Object

'Path to word document
C20GBCOV = InspectionFormQry(Me.PartID)

'Create instance of Word
Set OpenWord = CreateObject("Word.Application")
OpenWord.Visible = True

'Open the document
OpenWord.Documents.Open FileName:=C20GBCOV

DoCmd.SetWarnings True

and the query is

SELECT InspectionFormsTable.InspectionFormPath, PartsTable.PartID
FROM InspectionFormsTable INNER JOIN PartsTable ON InspectionFormsTable.InspectionFormID = PartsTable.InspectionForm
WHERE (((PartsTable.PartID)=[PartID_par]));
 
there are a couple of ways to approach this, depending on how the data is stored in the word doc. Using automation to 'walk' through the word doc finding the text you want. Importing 'chunks' of text into an import table where you can manipulate and search the string for keywords. If it is a table, it makes things a little easier.

Have a look at this thread for some pointers http://www.access-programmers.co.uk/forums/showthread.php?t=57072&highlight=import+word

Of course the 'best' route is to stop using word:p. Do everything through Access. The drawing is a problem, but the easy way around that is to have a sub routine that creates a new image file in the format you use, to a file protocol, save it and then open that new blank image. This way when the user saves the image, the file name is already known and stored in your DB. You can then access the iamge file in the many different ways available
 
Last edited:
Hi - thanks for your reply. There are many inspection reports and they sometimes have to be edited so I think it is best that they remain in a Word format. I thought there would be a simple way to merge the Access data into the Word document.
 
Merging Access into Word is easily done through the mailmerge function. You can either run that direct from the word document, or use automation to drive the mail merge from Access.

I thought you wanted to merge info in the document INTO Access:rolleyes:
 
Can you tell me what the code would be to put the WO Info from Access into the Word Doc? Would I use bookmarks or merge fields on the word doc?
 

Users who are viewing this thread

Back
Top Bottom