Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. ImportStylesheet[fn_] :=
  2. Module[{nbk}
  3. , nbk = NotebookOpen[fn];
  4. If[nbk == $Failed
  5. ,Print["ImportStylesheet: Wrong Filename"];
  6. Throw["Wrong filename!"]
  7. ];
  8. SetOptions[EvaluationNotebook[]
  9. ,Sequence[Options[nbk
  10. , StyleDefinitions
  11. ]
  12. ]
  13. ];
  14. NotebookSave[nbk, fn]; (* might have been open before *)
  15. NotebookClose[nbk]; (* closes it without asking *)
  16. ];
  17.  
  18. Part of the path ...(my nb's full path)... does not exist. Unable to
  19. save the file ....
  20.  
  21. ImportStylesheet::usage =
  22. "ImportStylesheet[fn]nImport the private Stylesheet of the Nb designated by fn. If this Nb was open before, it will be stored automatically at the end of this function to prevent loosing edits by closing the nb.";
  23. ImportStylesheet[fn_] :=
  24. Module[{nbk}
  25. ,nbk = NotebookOpen[fn];
  26. If[nbk == $Failed
  27. ,Print["ImportStylesheet: Wrong Filename: ", fn];
  28. Throw["Wrong filename!"]; (* ====THROW===> *)
  29. ];
  30. SetOptions[EvaluationNotebook[]
  31. ,Sequence[Options[nbk
  32. ,StyleDefinitions
  33. ]
  34. ]
  35. ];
  36. NotebookSave[nbk]; (* the nb might have been open before *)
  37. NotebookClose[nbk];(* this would close it without asking *)
  38. ]; (* ImportStylesheet *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement