#include "wdconstants.h" _CLIPTEXT = "WhatEverYouWantHereSeparateWithTabsForTableDataUsingApplicationDataToClipOrLowLevelI/O" oWord = createobject("Word.Application") WITH oWord .Documents.Open("c:\myPath\myTemplate.doc") lcMyBookMarkName = _VerifyBookMark(oWord,"DoesThisExist", "myTableHere") WITH toWord.ActiveDocument .Bookmarks(lcMyBookMarkName).Select WITH .Application.Selection .Collapse(wdCollapseEnd) && Go to end of bookmark IF .Information(wdWithInTable) && If we're in a table .MoveEnd(wdTable) .Collapse(wdCollapseEnd) && Get out of table .InsertParagraph() && Split table .Collapse(wdCollapseEnd) && Clear selection ENDIF .Text = _cliptext && Paste clip data lnWidth = tnPageColWidth / fcount() && Calculate evenly distributed width loTable = .ConvertToTable(wdSeparateByTabs,,lnHeaders,lnWidth, ; wdTableFormatColorful2,,,,,,,.f.,,.f.) && Convert to table format Colorful 2 .Find.Execute("~",,,,,,,,,chr(13),wdReplaceAll) && Restore memo para marks .Rows.AllowBreakAcrossPages = .f. && Do not let row break if doesn't fit on same page .Collapse(wdCollapseEnd) ENDWITH ENDWITH ENDWITH ************************************************************************************* * Verify existence of bookmark - If not exist create one with tcTableName at EndOfDoc ************************************************************************************* FUNCTION _VerifyBookMark LPARAMETERS toWord, tcBookmarkName, tcTableName IF type("tcBookmarkName") = "L" ; or ( type("tcBookmarkName") = "C" and empty(tcBookmarkName) ) ; or upper(tcBookmarkName) = "\ENDOFDOC" ; or !toWord.ActiveDocument.Bookmarks.Exists(tcBookmarkName) WITH toWord WITH .Selection .EndKey(wdStory) .InsertParagraphAfter() ENDWITH WITH .ActiveDocument IF !(type("tcBookmarkName") = "C" and ; !empty(tcBookmarkName) and ; !.Bookmarks.Exists(tcBookmarkName) ) tcBookmarkName = tcTableName ENDIF IF !.Bookmarks.Exists(tcBookmarkName) .Bookmarks.Add(tcBookmarkName) ENDIF ENDWITH ENDWITH ENDIF RETURN tcBookmarkName ************************************************************************************* * Verify existence of bookmark - If not exist create one with tcTableName at EndOfDoc *************************************************************************************The use of this routine is that you insert the table (in clipboard) to a bookmark if that exists or to endofdoc if that doesn't.