Printing in Excel with an incremented ref. number


This is the script I have elaborated to print several copies of a same document, with an incrementing reference number, that I am delighted to share with you, folks :

—AppleScript permettant d’imprimer plusieurs documents en renumérotant à chaque impression
— ouvre une fiche en naviguant dans les dossiers
—il est nécessaire que la cellule où se trouve le numéro soit intitulée “numero” sans accent
—AppleScript to print a same document with subsequent reference number
—open the document from the finder
—the cell where the reference number is to increment must be named “numero”

set mon_classeur to choose file “Chose an Excel file”
tell application “Microsoft Excel”
open mon_classeur
— récupère le dernier numéro (nombre) imprimé — (get the last reference number printed)
set ma_cellule to cell “numero”
select ma_cellule
set nombre to value of ma_cellule
— demande à l’utilisateur la plage d’impression — (request for a printing range)
set {text returned:firstNumber} to display dialog “Print from card :” default answer nombre + 1
set {text returned:lastNumber} to display dialog “to card :” default answer nombre + 10
— imprime les fiches correspondantes en les renumérotant chaque fois – print the cards with an incremented ref number
tell application “Microsoft Excel”
repeat with nombre from firstNumber to lastNumber
set value of ma_cellule to nombre
delay 1
print active sheet
end repeat
end tell
end tell

I am not very happy with the fact that it shows the print dialog every time it prints a form !
Could anyone give me a clue how to make it simple straight forward ? Thank you stefanK for your help so far, can we make it better



Model: MacBook Pro
Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)

please read the dictionary of Excel

the print command has a boolean print dialog parameter,
or Excel has a more specific print out command