-- This code should work in versions of ToolBook 6.5 and higher to handle buttonClick -------------------------------------------------------------------- -- Update this line with the reference to the file you wish to save. -------------------------------------------------------------------- fName = "c:\temp.doc" -------------------------------------------------------------------- -- Update this line with the reference to your field, note that -- this field must be on the current page. -------------------------------------------------------------------- fld = field "foo" select text of fld send copy focus = null bs = ASYM_BlockSuspend() wordObject = createAutoObject("Word.Application") err = ASYM_RestoreSuspend(bs) if err <> NULL OR wordObject = NULL request "Can't open Microsoft Word." break end bs = ASYM_BlockSuspend() emptyDoc = extAdd() of extDocuments of wordObject err = ASYM_RestoreSuspend(bs) if err <> NULL OR emptyDoc = NULL request "Can't create a new document" get closeAutoObject(wordObject) break end bs = ASYM_BlockSuspend() get extSaveAs(fName) of emptyDoc err = ASYM_RestoreSuspend(bs) if err <> NULL request "Error saving Word Document" get closeAutoObject(wordObject) break end get extPaste() of extSelection of wordObject get extSave() of emptyDoc get extClose(0) of emptyDoc end -- Close the Automation Object to get closeAutoObject obj bs = ASYM_BlockSuspend() get extQuit(0) of obj get ASYM_RestoreSuspend(bs) return null end