MathGroup Archive 2008

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

Search the Archive

Re: Deleting parts of notebooks programmatically

  • To: mathgroup at
  • Subject: [mg89230] Re: Deleting parts of notebooks programmatically
  • From: David Reiss <dbreiss at>
  • Date: Fri, 30 May 2008 02:56:50 -0400 (EDT)
  • References: <g1m8il$ju$>

It seems like the problem that you are having with your Manipulates
not rendering is a bug.  It certainly doesn't happen if the material
is copied and pasted "by hand."  So this suggests using a temporary
notebook to write the material to and then to copy and paste it into
the desired notebook.  In the following nb is the NotebookObject of
the notebook that you want to remove the part of.  I am omitting the
part replacement code here:

thenb = NotebookGet[nb];
tempnb = CreateDocument[{}, Visible -> False];
NotebookPut[thenb, tempnb];
SelectionMove[tempnb, All, Notebook];
FrontEndExecute[FrontEndToken[tempnb, "Copy"]];
SelectionMove[nb, All, Notebook];
FrontEndExecute[FrontEndToken[nb, "Paste"]];

I hope that this helps...


On May 29, 8:46 am, "J. McKenzie Alexander" <ja... at> wrote:
> Suppose that I have a part specification (as returned by Position) for  =

> a component of the current InputNotebook[] that I would like to  
> delete, and that this part specification was determined  
> programmatically.  As a first guess I would try to use the function  
> NotebookDelete - except that only deletes the current *selection* in  
> the specified notebook, and there doesn't seem to be any easy way of  
> using SelectionMove to set the current selection so as to correspond  
> exactly to the region given by a part specification...
> The only solution I've found is the following::
>         nb = NotebookGet[ InputNotebook[] ];
>         pos = Position[ nb, ..... ];
>         NotebookPut[ Delete[nb, pos], InputNotebook[] ]
> The problem is that this breaks any Manipulates appearing in the  
> notebook (any displayed graphic appears greyed out and doesn't ever  
> display correctly again until the notebook is closed and re-loaded).
> In case anyone wants to see what motivates this, and an example  
> showing the Manipulate bug, here's a simple notebook which implements  
> endnotes in Mathematica (version 6 and higher).  Do keep in mind that =
> it's a beta, and not very robust yet.
> Cheers,
> Jason
> --
> Dr J. McKenzie Alexander
> Department of Philosophy, Logic and Scientific Method
> London School of Economics and Political Science
> Houghton Street, London WC2A 2AE
> Please access the attached hyperlink for an important electronic communica=
tions disclaimer:

  • Prev by Date: Re: Bug in Default[] or Bug in My Understanding?
  • Next by Date: Re: Datafunctions - multiple keys
  • Previous by thread: Deleting parts of notebooks programmatically
  • Next by thread: Datafunctions - multiple keys