Option Explicit
Public Sub GetExcelData()
Dim objExcel As Excel.Application
Dim wkbk As Excel.Workbook
Dim ws As Excel.Worksheet
Set objExcel = CreateObject("Excel.Application")
Set wkbk = objExcel.Workbooks.Open("c:\temp\book1.xls")
Set ws = wkbk.Sheets(1)
ws.Range("A1").Copy
Selection.Paste
wkbk.Close savechanges:=False
objExcel.Quit
End Sub
Change the bits in red to point to an existing workbook - we can change this to a dialog box later, but this will do for now - and a cell in that workbook whose value you know. Go Tools > References in the VBA editor and add a reference to the Microsoft Excel Object Library. (This 'teaches' Word how to handle Excel objects.)
Return to the Word document and go Developer > Macros > GetExcelData > Run. Does the cell you specified get imported from the workbook to the Word document?
If so, great, that bit works. Now you just need to:-
Get the process error number from your form and pass it to the VBA code
Write a routine to find the process error number in the Excel workbook
Return the contents of the appropriate record back to the form
I can help you with (2) but I've not really done anything with Word, so I don't know enough about it to read data from a form and return data to it. You'd need to find someone else to help with (1) and (3).