Jump to content
Sign in to follow this  

Update Existing CTOC in FrameMaker

Recommended Posts


This code lets you auto-update the chapter TOCs in your Adobe FrameMaker documents. There is some minimal problem condition-anticipating code, but it's a fairly dumb script. You must have only one document open in FrameMaker, or if you have more than one open, they must all be minimized. If there is more than one Frame doc open and not minimized, the script it likely to malfunction.

I welcome suggestions for improvement, if anyone has ideas. I spent about six hours hashing out this, my first AutoIT script. I swiped and modified some code from Slim Shady to house my code in a GUI window (thanks, Slim).



;================= Example of a GUI =================


; AutoIt version: 3.0.103

; Language: English

; Author: "SlimShady" (GUI window)

; Doug Bailey (CTOC update script)


; ----------------------------------------------------------------------------

; Script Start

; ----------------------------------------------------------------------------

;Include constants

#include <GUIConstants.au3>

;Initialize variables

Global $GUIWidth

Global $GUIHeight

;Initialize flag for While loop

Global $WFlag

$WFlag = 1

$GUIWidth = 180

$GUIHeight = 40

;Create window

GUICreate("Update CTOCs", $GUIWidth, $GUIHeight)

;Create an edit box with no text in it

;$Edit_1 = GUICtrlCreateEdit("", 50, 50, 20, 10)

;Create an "OK" button

$OK_Btn = GUICtrlCreateButton("Update", 22, 10, 70, 25)

;Create a "CANCEL" button

$Cancel_Btn = GUICtrlCreateButton("Exit", 97, 10, 60, 25)

;Show window/Make the window visible


;Loop until:

;- user presses Esc

;- user presses Alt+F4

;- user clicks the close button

While $WFlag

;Pause a bit so the script doesn't use alot of CPU time


;After every loop check if the user clicked something in the GUI window

$msg = GUIGetMsg()


;Check if user clicked on the close button

Case $msg = $GUI_EVENT_CLOSE

;Destroy the GUI including the controls


;Exit the script


;Check if user clicked on the "OK" button

Case $msg = $OK_Btn

;MsgBox(64, "New GUI", "You clicked on the OK button!")

; Wait for FrameMaker to receive focus, then create new CTOC

WinActivate ("Adobe FrameMaker")



Send ("{LEFT}")

Send ("{ALTDOWN}Sb")

Send ("{ALTUP}")

Send ("{ENTER}")

Send ("{ALT}C")

Send ("{ENTER}")

; Save and close CTOC; focus returns to the parent document


Send ("^s")


Send ("^W")

; Select the CTOC by selecting the entire text flow


Send ("^F")

Send(" ")


Send ("^A")

; Update the text inset CTOC


Send ("{ALTDOWN}Eiu")

Send ("{ALTUP}")


Send ("^s")

WinActivate ("Update CTOCs")

;Check if user clicked on the "CANCEL" button

Case $msg = $Cancel_Btn

$WFlag = 0




;=== End Script ===


Share this post

Link to post
Share on other sites

You could add a few more steps to improve it:

Open all docs in the book.

Search for any text inset. Ask the user whether the selected text inset is a TOC.

If yes, update it.

If you need details, let me know.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this