select ... into table (lcFreeTableName) && Select recs into a temp table lcFreeTable = alias() lcDefDir = sys(5)+curdir() * Prepare DSN strings cDSN = "DSN=FoxPro Files;DBQ="+lcDefDir+";DefaultDir="+lcDefDir+";" cSourceDB = "" cSourceType = "" cOther = "DriverId=536;MaxBufferSize=512;PageTimeout=5;" cDataSource = dbf(lcFreeTable) cSQLStatement = "SELECT * FROM "+lcFreeTableName+".dbf" * Save caption names to array aFieldAndCaptionNames DIMENSION aFieldAndCaptionNames[fcount(),2] FOR ix = 1 to fcount() aFieldAndCaptionNames[ix,1] = field(ix) ENDFOR USE SELECT field_name,label_grid from (DefaultDataPath + LookupData) ; where file_name = tcTableName ; into cursor myDD2 FOR ix = 1 to alen(aFieldAndCaptionNames,1) aFieldAndCaptionNames[ix,2] = trim(aFieldAndCaptionNames[ix,1]) && if !locatable use default LOCATE for field_name = aFieldAndCaptionNames[ix,1] if !eof() aFieldAndCaptionNames[ix,2] = trim(label_grid) endif ENDFOR USE .Bookmarks(tcBookmarkName).Range.Collapse(wdCollapseEnd) * Insert table data to word oRange = .Range(.Bookmarks(tcBookmarkName).Range.Start, .Bookmarks(tcBookmarkName).Range.End) oRange.InsertDatabase( ; wdTableFormatContemporary, 47, 0, ; cDSN+cSourceDB+cSourceType+cOther, ; cSQLStatement, ,,,,, cDataSource,,,1) oRange = .NULL. * Set the heading row fieldnames to label_grid captions from dd2 table WITH .tables(tnTableNumber) FOR ix = 1 to alen(aFieldAndCaptionNames,1) _SetCellHeading(ix,aFieldAndCaptionNames[ix,2]) ENDFOR ENDWITH erase (lcFreeTableName+".*") && Erase temp file(s)Cetin