; This AutoIt-macro copies records from a FM-Database to MS-Word for Windows, ; preserving character-formatting due to the XML-structure. ; The trick is: Instant-Web-Publish the database you want to export in FM-Pro 5 ; (does not work with PM-Pro 4) ; (trick (c) by Christoph Bouthillier p o s t [a--t t e k s t o t a a l [a dot] c o m) ; Restrictions: ; 1. As web-browser you have to use Internet Explorer, it won't work with ; Netscape ; 2. You can export only one field at a time. ; Preliminary steps to do: ; 1. Setup AutoIt: ; ================ ; - Download and install the freeware AutoIt from http://www.hiddensoft.com/AutoIt/ ; 2. Setup your Filemaker database: ; ================================= ; - Create a layout, which contains only the field you want to export. ; - Instant web publish your database. ; 3. Setup IE: ; ============ ; - Open your previously published database in IE. ; - Change mode to "form". ; - The window title should now start with the word "form" (This is important ; for the macro to work.) ; 4. Setup MS-WORD: ; ================= ; - Create an empty document. Save it as "FM_Export.doc". ; Now you should have 3 programs open: ; 1. FM Pro 5 (with your DB) ; 2. IE (Active window's title starts with: Form) ; 3. MS-WORD (Active window's title starts with: FM_Export) ; Before you start exporting, please read on. You might have to adjust ; some settings. ; MACRO BEGIN ; You start by entering the number of records you want to export. Starting ; point of the export is the current record shown in IE. ; Thus, if you want to export *all* records, you have to assure that in ; IE the *first* record is shown AND that you enter the number of all ; records in the following input box. ; Note: We don't do any error-checking. So be careful to enter only numbers ; in the allowed range. InputBox, NUMBER_OF_RECORDS_TO_EXPORT, AutoIt, Please enter the number of records you want to export (starting from the current record). ; Now we activate and maximize the IE-window WinActivate, Form WinMaximize, Form ; and move to the little input-box, which shows the number of the current ; record. Send, {TAB 2} ; we copy that number to the clipboard Send, ^c ; and store it into the variable CURRENT_RECORD_NUMBER SetEnv, CURRENT_RECORD_NUMBER, %CLIPBOARD% ; now we set up a loop. We will loop NUMBER_OF_RECORDS_TO_EXPORT times. Repeat, %NUMBER_OF_RECORDS_TO_EXPORT% ; We triple click on the entry, thus selecting the whole entry. ; (You might have to adjust the following coordinates, depending ; on the size of your monitor. You can use AutoIt /reveal to get ; the proper coordinates.) LeftClick, 170, 202 LeftClick, 170, 202 LeftClick, 170, 202 ; and copy the whole entry to the clipboard Send, ^c ; Now we activate the MS-WORD window WinActivate, FM_Export WinMaximize, FM_Export ; and paste the entry (formatting is preserved, when you copy ; from IE to WORD!) Send, ^v ; wait till pasting is done (if you have a very slow computer ; you might have to increase that value. For me 50 ms works fine.) SetKeyDelay, 50 ; Set the cursor into the next line Send, {ENTER} ; Reset the delay to 20 ms SetKeyDelay, 20 ; Go back to IE WinActivate, Form WinMaximize, Form ; increase CURRENT_RECORD_NUMBER by one EnvAdd, CURRENT_RECORD_NUMBER, 1 ; move again to the little input-box, which shows the number of the ; current record Send, {TAB 2} ; increase that number by entering the new value Send, %CURRENT_RECORD_NUMBER% ; and confirm Send, {ENTER} ; now IE loads the next record. This might last a while. So a delay ; has to be considered. Again that value depends on the speed of ; your computer. For me 2 secs work fine. SetWinDelay, 2000 WinWaitActive, Form ; Restore the Win delay. SetWinDelay, 10 ; Now the next record is shown and we can loop back to copy it .... EndRepeat ; Go back to Word. WinActivate, FM_Export WinMaximize, FM_Export ; Show a message that export is finished. MsgBox, 64, AutoIt, Export of data finished. ; This macro was created on July/21/2000 by Helmut Kalb (helmut.kalb@uibk.ac.at)