FileMaker Script Printing with Dynamic # of Copies

Good Evening.

After several hours of web searching, and not finding the answer … it’s time for an email list post.

I have a database called “centers” with about 50-100 records.
One of the fields is called “numcopies”
One layout is called “cover letter”
One layout is called “flyer”
The two layouts are personalized for each record.

I’d like to run a script that goes through each of the records in the database. For each record, I would like to print one copy of the cover letter (the layout called “cover letter”). After that one page is printed for a record, I want to print the flyer for each record … but I want to print the number of copies specified by “numcopies” for that record.

Simple Example:
Let’s say that we have two centers: LA and NY. LA needs 50 copies of the flyer, and NY needs 25 copies of the flyer. Remember, the flyers for each location are different not only by quantity, but that they are “personalized” (e.g., one flyer prints with LA on it, and the other with NY on it).

I want to have a resulting stack of paper that looks like this:

Single page cover letter to LA
50 copies of the flyer personalized to LA
Single page cover letter to NY
25 copies of the flyer personalized to NY

The problem:
I’m happy for this to be in either ScriptMaker or AppleScript, but I’ve been unable to find a good solution.

Clearly, I can print with ScriptMaker, but I cannot dynamically specify the copies.

It’s probably possible with AppleScript, but since I generally find AppleScript to be a “read only” language , I could certainly use some examples to pilfer from. :slight_smile:



Moved to AppleScript | OS X. Code Exchange is for finished snippets, AppleScript | OS X is for questions.

Filemaker 8 (?) and up allows you to define variables in a script step.

Hope this helps.


Thanks for the tip on variables.

The problem isn’t so much in determining the number, it’s how to communicate that number to the print command.

That said, I’ve not yet been able to track down a good example of using AppleScript to tell FileMaker to print. That could very well do the trick if anyone has an example of that using the more extended print parameters (like number of copies).



a quick google search turned up this link which presents a very good concept for storing print settings in individual script steps. You can do this then use variables within a fm script to call a particular script step based on whatever quantity you need.

Otherwise, I was able to check the FM Pro 8 library and it seems the print function in Applescript is pretty simple. What have you got so far?


An interesting read. Unfortunately, this would mean that for each quantity, I’d have to set up a script, or use combinations of them. In other words, I’d have to have a script for each of these:

Print 1 copy
Print 2 copies
Print 3 copies
Print 4 copies
Print 5 copies
Print 10 copies
Print 20 copies


Alternatively, I could do one page prints over and over again until I reach the quantity – but since the flyer is a complex graphic, it would take forever to print, when it should be rasterized once.

In short, I have a very tough time writing AppleScript from scratch. I can read it. I can copy/paste and modify it. But, I can never get the syntax right – and usually, I cannot get past the compile. Because I don’t do AppleScript all the time, I never reach a fluency level … even though I’ve cobbled together tons of scripts over many years.

So, what I’m looking to do is something like:

tell application “FileMaker Pro Advanced”
tell window “xyz”
goto layout “abc”
print quan copies
end tell
end tell

obviously NOT real AppleScript but you get the idea (the 3rd line is bogus, but I can figure that out). The problem is the 4th line. I cannot get the right syntax for that. Any ideas?



directly from the dictionary works for me:

print yourobject with copies 2


Sorry, should have been a bit more explicit – I had forgotten where I stumbled before.

I could never figure out how to properly specify or define “yourobject”. Sorry to be so AppleScript lame … as I do understand this should be a run of the mill direct parameter reference. I just can’t figure out the right syntax for it.

Any help would be appreciated.

I don’t use FileMaker, so can’t answer how to specify an object from FM for printing, but the dynamic part (i.e. the number to print goes like this):

repeat -- only exits are "Cancel" or a proper positive integer input
	set N to text returned of (display dialog "Enter an integer number of copies to print" default answer "")
		set N to N as integer
		if N > 0 then
			exit repeat
			display dialog "The number must be positive"
		end if
	on error
		display dialog "That was not an integer"
	end try
end repeat
N -- the variable to use in the print command.

That’s a pretty useful piece of code.

I was trying to figure out actually the reference object for the AppleScript. I just came across this and have gotten it work:

tell application "FileMaker Pro Advanced"
	print window 1 with copies 2
end tell

In the final solution, I can call that now from within a ScriptMaker script (executing native AppleScript) and that should work.

The problem is that FileMaker is ignoring what I tell it, and going with whatever was the last print settings done from the user interface. Let me explain:

tell application "Printer Setup Utility"
	set current printer to printer ""
end tell

tell application "FileMaker Pro Advanced"
	tell document "Training Centers"
		go to layout "Cover Letter"
		print window 1 with copies 1
		go to layout "Coupon Flyer"
		print window 1 with copies 3
	end tell
end tell

In this script, I’m setting the printer to the printer I want to use someprinter1, and then printing 1 copy of the cover letter, and 3 copies of the flyer. BUT, that’s not what end results.

Since the last print job I did from the printer was to print to someprinter2 (note different printer), and I printed 2 copies of something, it does that again. In other words…

I want this:
Printed on someprinter1
1 copy of the cover letter
3 copies of the flyer

and I get this:
Printed on someprinter2
2 copies of the cover letter
2 copies of the flyer

because apparently FileMaker feels that it should do what was done last time, not what I’m specifying. What’s interesting is that I can see from the printer list in the Printer Setup Utility that the default (e.g., current) printer is properly set to someprinter1.

In part, this problem is described at – but the solution listed there doesn’t work in this case. I just need to find a way to get FileMaker to do what I ask by either an AppleScript or a ScriptMaker script.

Any ideas?



This might help Neil:

Yeah – unfortunately, no. What this is shows how to get FileMaker to memories something that you’ll want to use repeatedly. In other words, it’s explaining how FileMaker goes about tracking this information.

Specifically, we want AppleScript to override what this is doing.



See my second post:)


Yep … I did. Unless I’m missing something, the only way that I can use that is if I have a Windows machine to create a replacement file for a file that I’ve not been able to find on my machine anyway. It was good about explaining why this is happening, but there was no solution I could implement.


That link really just reviews a concept. Note the part that states:

You may want to read the section on scripts in the Filemaker Help menu to familiarize yourself how they work.

Good Luck


Yep – read and re-read them.

I want to do a script without human interaction needed … which would defeat the purpose of the script.

It APPEARS that if you quit from FileMaker, and then go back into it, it will refresh the settings. This is too much of a pain, and I’m at the point where I’m sick of this problem (as I’m sure you are).

I’ve resorted to not using AppleScript and printing each copy one at a time using a stored print command in ScriptMaker.

Oh well.

Thanks for the help,

Hmmm. In case you do come back and read this:

i just created a new DB in Advanced 8.5, Created two scripts each containing a print setup step followed by a print step with Specify Options and Perform Without Diallog selected. The options for one of the scripts specified 6 copies and the other script specified 2 copies. This took about one minute per script. No tricks, no secrets.

I then quit and reopened and tried each script“ one printed 2 copies the other printed 6. Confirmed it worked in v 8.0 Pro also.

Are you sure your software is OK? It seems like something isn’t right on your end.



I just did a quick test…

tell application "Printer Setup Utility"
	set current printer to printer "HP Laser"
end tell

tell application "FileMaker Pro"
	print window 1 with copies 5
end tell

… and confirmed that FileMaker does indeed use the last printer that was used, and not necessarily the printer that I have specified in the “Printer Setup Utility”. To work around this issue, here are some suggestions…

a) You could use GUI scripting to simulate user interaction to select the printer and type the number of copies into the print dialog. For example:

tell application "System Events"
	tell process "FileMaker Pro"
		set frontmost to true
		keystroke "p" using command down
		repeat until window "Print" exists
		end repeat
		tell window "Print"
			keystroke "20" -- number of copies
			tell pop up button 3
				tell menu 1
					click menu item "HP Laser" -- Your printer name
				end tell
			end tell
			keystroke return -- depress the "Print" button
		end tell
	end tell
end tell

b) You could create a FileMaker script step that prints the layout to PDF, and then have AppleScript take over, open the PDF in something, such as Adobe Acrobat Professional, and print it X number of times from there.

Hope this helps.



Most helpful. I believe that will do the trick.



That sure is some solution! Hope it works for you.