Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Notebook that auto-executes when opened?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97310] Re: Notebook that auto-executes when opened?
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Tue, 10 Mar 2009 05:38:10 -0500 (EST)

Hi,
I do not know the answer to your question as it is. However, I have a 
very alike procedure. If you have some Mathematica notebook that already 
has been open, you may execute few simple commands that will open the 
notebook that you  have in mind, open the cell groups (if any), execute 
all executable cells (if any) and return to the initial structure (that 
is close cells groups, if any). As the result you have the notebook with 
all operators executed when open. In case this may help you, please have 
a look below:

nb1 = NotebookOpen[
  "Full_path_to_your_notebook_to_be_open_and_executed"]  (* This opens 
your notebook  *)

FrontEndTokenExecute[nb1, "SelectAll"]                                   
(* This selects all cells in it in order to... *)

FrontEndTokenExecute[nb1, "OpenCloseGroup"]                      (* 
...open all cell groups, if any  *)

FrontEndTokenExecute[nb1, "EvaluateCells"]                              
(*  ...and execute all executable cells  *)

FrontEndTokenExecute[nb1, "SelectAll"]                                (* 
This again selects all cells in it in order to...  *)

FrontEndTokenExecute[nb1, "SelectionCloseAllGroups"]         (* ...close 
all cell groups to represent your notebook in a most compact form *)


You may need or may not need the last two steps. If you have no cell 
group structure, you do not need also the step 3.

Have fun and success, Alexei





 

AES wrote:
> Possible to set an option for a notebook such that it automatically 
> begins executing when opened, that is, when the nb icon is dbl-clicked 
> on the desktop, or however else files are opened in the operating system 
> that's being used?
> 
> I guess I'm also assuming here an OS which, along with opening the file 
> itself, if necessary first opens the app which executes the file, since 
> that's the only type of OS that I'm familiar with.  Are there any 
> Mathematica compatible operating systems that don't do this?
> 



-- 
Alexei Boulbitch, Dr., Habil.
Senior Scientist

IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 Contern
Luxembourg

Phone: +352 2454 2566
Fax:   +352 2454 3566

Website: www.iee.lu

This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal from your system. Thank you for your co-operation.




  • Prev by Date: Re: Memory leak in StringSplit in Mathematica 7
  • Next by Date: Re: Memory leak in StringSplit in Mathematica 7
  • Previous by thread: Re: Re: Notebook that auto-executes when opened?
  • Next by thread: Re: Notebook that auto-executes when opened?