I have a notebook called CardManipulation2.nb
it contains data, a list of 101 strings
I would like to move (Export?) data [[1]] to notebook CardManipulation1.nb
I also have a notebook titled (perhaps incorrectly) “X2382901”.nb
and would like to move data [[13]] to it
I can’t find the proper incantation to accomplish. I’ve tried a bunch of Export* 's
dlkeith
(David Keith)
October 10, 2021, 9:24pm
2
Look at the documentation on DumpSave and Get. You could use them to transfer the entire list. You could also transfer a particular string by assigning it to a separate symbol.
Kind regards,
David
ahmed
(Ahmed Elbanna)
October 11, 2021, 6:18pm
3
You can also use Iconize[ ] . The resulted object is easy to copy, paste and saved in any notebook.
gdelfino
(Gustavo Delfino)
October 11, 2021, 7:35pm
4
Here I move a list of 101 strings into a new notebook:
CreateDocument[ExpressionCell[RandomWord[101]]]
You could also insert into an existing notebook.
To append to an existing notebook
list = RandomWord[5]
(* Open existing notebook *)
X2382901 = NotebookOpen[FileNameJoin[{Directory[], "X2382901.nb"}], Visible -> False];
(* Move selection point to end of notebook *)
SelectionMove[X2382901, After, Notebook];
(* Insert *)
NotebookWrite[X2382901, Cell["list = " <> ToString[list, InputForm], "Input"]]
(* Save *)
NotebookSave[X2382901]
Apologies to all for repeating a question, but I have been unable to get the replies to work
The following two commands did work
XRef = NotebookOpen[FileNameJoin[{Directory[], "XRef.nb"}],
Visible -> False];
SelectionMove[XRef, After, Notebook];
I have a string variable defined as follows
xRefcardTitle = "XREF " <> cardName <> " " <> cardID
Which yields – “XREF "X2383901" 2580879”
The following fails
NotebookWrite[XRef, Cell[xRefcardTitle , "Input"]]
xRefcardTitle
Yielding
NotebookWrite[$Failed, Cell["XREF \"X2383901\" 2580879", "Input"]]
How do I write this simple string variable (xRefcardTitle) to Xref.nb ?
This works fine, which is the same as the code in the answer above except that there is no symbol the string is set to.
xRefcardTitle = "XREF \"X2383901\" 2580879";
XRef = NotebookOpen[FileNameJoin[{Directory[], "XRef.nb"}], Visible -> False]
SelectionMove[XRef, After, Notebook];
NotebookWrite[XRef, Cell[ToString[xRefcardTitle, InputForm], "Input"]]
Does this file exist?
FileNameJoin[{Directory[], "XRef.nb"}]
Please learn how to format code in your questions. Read the “Post Editor” and “Code Formatting” sections here .
Rohit
Xref.nb does exist. I created it using the file menu
All I did to get
XRef = NotebookOpen[FileNameJoin[{Directory[], "XRef.nb"}], Visible -> False]
Was take your example
X2382901 = NotebookOpen[FileNameJoin[{Directory[], "X2382901.nb"}], Visible -> False];
And replace X2382901 by Xref and replace X2382901.nb by Xref.nb
So I’m assuming that
FileNameJoin[{Directory[], "XRef.nb"}]
exists
Once again, thanks for your patience with me.