5
$\begingroup$

I'm trying to create a Button that - when pressed - creates a report using a template. Here is a minimal example:

Button["Test",
    GenerateDocument[
        "ExampleData/BasicTemplate.nb", <|"author" -> "Henry Jones"|>
    ]
]

This creates the Button, but when clicked I get an error "Could not process unknown packet "1"." (or with another number there).

Trying the raw action:

GenerateDocument[
    "ExampleData/BasicTemplate.nb", <|"author" -> "Henry Jones"|>
]

just works fine and opens the generated report as expected.

What's going wrong with the Button action? I've tried Button with CreateNotebook[] as action, and that works fine, so in principle Buttons can open new notebooks, just not in combination with GenerateDocument it seems.

Thanks for any help.

$\endgroup$
7
$\begingroup$

Add the option Method -> "Queued":

Button["Test", 
 GenerateDocument["ExampleData/BasicTemplate.nb", <|"author" -> "Henry Jones"|>], 
 Method -> "Queued"]
$\endgroup$
  • $\begingroup$ Incredibly fast and correct answer. Thanks! $\endgroup$ – Stephan Jan 14 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.