Document

Performs various operations on projects. Special counting and looping options are available.

Please see the pe_dir X-Function.

Contents

Syntax:

document option argument

Options:

-a fileName; Append the contents of fileName to the current project(Without running [AfterOpenDoc] )

Syntax: doc -a fileName

Append the contents of fileName to the current project. fileName must be a full path description, including the file extension. fileName can be a project file or child window file or an Excel file.

Notes: The [AfterOpenDoc] section of the ProjectEvents.ogs will not be run if using this command. If you want the section to run, refer to
doc '''-as''' ''fileName''

-af projectName [folderName]; Append a folder as a sibling to the current folder

Syntax: doc -af projectName [folderName]

Append the specified folder in another Origin project or another whole Origin project as a sibling to the current folder. Add as a parallel folder to the current folder unless the current folder is the root; then add as a subfolder. projectName must be a full path description, including the file extension. folderName should exclude the project root folder. For example:

//Active Folder1 manually
doc –af "%Ytest.opj" "Folder2InTestOPJ/FolderA";

-af.png

//Append the whole project as a sibling to Folder1
doc –af "%Ytest.opj";

-af-2.png

-afa projectName [folderName]; Append the contents of a folder to the current folder

Syntax: doc -afa projectName [folderName]

Append the contents of the specified folder in another Origin project or all contents in another Origin project to the current folder. projectName must be a full path description, including the file extension. folderName should exclude the root folder. For example:

//Active Folder1 manually
doc –afa "%Ytest.opj" "Folder2InTestOPJ/FolderA";

-afa.png

-afc projectName [folderName]; Append a folder as the subfolder of the current folder

Syntax: doc -afc projectName [folderName]

Append the specified folder of another Origin project or another whole Origin project as a subfolder of the current folder. projectName must be a full path description, including the file extension. folderName should exclude the root folder. For example:

//Active Folder1 manually
doc –afc "%Ytest.opj" "Folder2InTestOPJ/FolderA";

-afc.png

–afm projectName option1 folderName1 option2 folderName2 …; Append multiple folders to the specified location of the current project

Syntax: doc -afm projectName option1 folderName1 option2 folderName2

Append multiple folders of another Origin project to the specified location of the current project. projectName must be a full path description, including the file extension. folderName should exclude the root folder.

Note: In order to specify the destination folder, we would use three options: /R, /S and /C, in which /R means to be as a subfolder of the project root folder, /S means to be as the sibling to the current folder and /C means as to be a subfolder of the current folder.

For example:

//Active Folder1 manually
doc -afm "%Ytest.opj" /S "FolderA/Sub1-1" /R "FolderB/Sub2-1" /C "FolderB/Sub2-2";

-afm.png

-afr projectName [folderName]; Append a folder as a subfolder of the current project root folder

Syntax: doc -afr projectName [folderName]

Append the specified folder of aother Origin project or another whole project as a subfolder of the current project root folder. projectName must be a full path description, including the file extension. folderName should exclude the root folder. For example:

doc –afr "%Ytest.opj" "Folder2InTestOPJ/FolderA";

-afr.png

-afrs projectName [folderName]; Append a folder to the current project root folder and then run ProjectEvents.ogs

Syntax: doc -afrs projectName [folderName]

Append a folder or another Origin project to the current project root folder and then run the ProjectEvents.ogs. projectName must be a full path description, including the file extension. folderName should exclude the root folder.

-afs projectName; Only run the ProjectEvents.ogs of a project without appending any folder

Syntax: doc -afs projectName

Only run the ProjectEvents.ogs of another Origin project without appending any folder. projectName must be a full path description, including the file extension.

-aimport fileName; Import an Excel XLS file

Syntax: doc -aimport fileName

Import an Excel XLS file into an Origin worksheet. See ImpExcel XFunction for a better alternative.

-as fileName; Append the contents of fileName to the current project(Force [AfterOpenDoc] to run)

Syntax: doc -as fileName

Append the contents of fileName to the current project. fileName must be a full path description, including the file extension. fileName can be a project file or child window file or an Excel file.

Notes: The [AfterOpenDoc] section of the ProjectEvents.ogs will force to be run if using this command.

-ca; Reactivate the autosave options dialog

Syntax: doc -ca

Minimum Origin Version Required: 8.5.0

Reactivate the autosave options dialog. This dialog appears when saving (and autosaving) a big OPJ file, where you can elect to turn off autosave. Run this command to open the dialog and reset autosave options (See the Note under Controlling autosave settings).

-cac; Dump the autosave status

Syntax: doc -cac

It will dump a message of autosave status.

-cas; Reactivate the autosave options dialog and save the current project

Syntax: doc -cas

Minimum Origin Version Required: 8.5.0

Reactivate the autosave options dialog and save the file. This dialog appears when saving (and autosaving) a big OPJ file.

-cl; Count layers in the active graph window

Syntax: doc -cl

Count layers in the active graph window. Assign the result to the variable count.

-cp name; Count all graph windows

Syntax: doc -cp name

Count all graph windows in the current project that match exactly or begin with name. Assign the result to the variable count.

-cs name; Count all datasets

Syntax: doc -cs name

Count all datasets in the current project that match exactly or begin with name. Assign the result to the variable count. A matrix is also counted as a dataset. Only Window Short Names of Workbooks and Matrices are searched.

-cw name; Count all workbooks

Syntax: doc -cw name

Count all workbooks in the current project that match exactly or begin with name. Assign the result to the variable count.

-d; Close the current project

Syntax: doc -d

Close the current project. Execute the DocEnd macro (if it has been defined). All windows are closed and no new project or windows are loaded. Do not exit Origin. Prompts to offer to save project.

-ddde; Open Project by EXE or DDE

Syntax: doc -ddde option

1 = open the Origin project by running the EXE
0 = open the Origin project by DDE

See FAQ-17 What should I do if double-clicking on my OPJ file fails to launch Origin?, Suggestion 2.

-e object {script}; Execute the given script for all objects

Syntax: doc -e object {script}

Execute the given script for all objects of the specified kind. This command makes an object active and executes the associated script, looping until each object of the specified type has been active. Most LabTalk commands, methods, and properties act on the active window. Use System Variables, when a name is required so that the loop script affects the active object. object can be one of the following :

D If a graph window is active, execute for all data plots in the active layer. If a worksheet is active, execute for all datasets (columns) in the active worksheet. (If a matrix is active, there is only one iteration.) %H contains the window name and %C the dataset name in each iteration.
DY If a graph window is active, execute for all data plots in the active layer excluding error bars and labels. If a worksheet is active, execute for all Y datasets (only) in the active worksheet. (If a matrix is active, there is only one iteration.) %H contains the window name and %C the dataset name in each iteration.
G Execute for all labels and other named objects in the active graph layer, the active worksheet, or the active layout page. %B contains the object name in each iteration. This is the same object collection as shown by list -o.
L Execute for all layers in the project. Note that a layout page has one layer, while a workbook, matrixbook, and graph can have multiple layers. %H contains the window name in each iteration. Page.active holds the active layer number. To express Page.active, for example, in a type statement, use $(page.active).
LB (8.0 SR3) Execute for all sheets in all workbooks and matrixbooks in the project. %H contains the current book name in each iteration. Page.active holds the active sheet index. See The Origin Project:Looping Over Objects.
LBC (2019b) Execute for all Data Connector-containing sheets in all workbooks and matrixbooks in the project. %H contains the current book name in each iteration. Books not having connectors will be skipped. For example, the following code will loop and convert the Data Source to Absolute Path.
doc -e LBC {
        %H=;
        page.Active=;
        wks.dc.SType=0;
}
LP Execute for all layers in all graph windows and Layout windows (only) in the project. %H contains the window name in each iteration. Page.active holds the active layer number.
LR ClassName (8.0 SR3) Execute script on specified report worksheet. Use doc -e LRW for all report sheets in active window.

The ClassName could be

Class Name Analysis tool
FitNL Nonlinear Fit
FitLinear Linear Fit
FitPolynomial Polynomial Fit
MR Multiple Linear Regression
DescStats Staitistcs on Columns
DescStats_1 Staitistcs on Rows
NormalityTest Normality Test
ANOVAOneWay One-Way ANOVA
ANOVATwoWay Two-Way ANOVA
ANOVAOneWayRM One-Way Repeated Measures ANOVA
ANOVATwoWayRM Two-Way Repeated Measures ANOVA
ROCCurve ROC Curves

For example:

document -e lr ANOVAOneWay
{
        tree tt;
        getresults tr:=tt;
        tt.=; // Type ANOVA report tree
}
LW Execute for all layers in the current window only. Note that a layout page has one layer, while a workbook, matrixbook, and graph can have multiple layers. %H contains the window name in each iteration. Page.active holds the active layer number.
M Execute for all matrixbooks in the project. %H contains the matrixbook name in each iteration. Note that this does not iterate at the sheet level. If the matrix created for an embedded image is visible, you can test the value of Page.isEmbedded property to determine that.
O Execute for all non-minimized windows in the project. %H contains the window name in each iteration. Note that an embedded graph - even one in a minimized workbook window - will be counted. Use the Page.isEmbedded property to determine if this is the case.
P Execute for all graph windows and layout windows in the project. %H contains the window name in each iteration.

(Note: To exclude graph windows embedded in a worksheet cell, you can test the value of Page.isEmbedded property.)

doc -e p {win -ppc} // Clean up all the graph previews from an OPJ
S Execute for all datasets in the project. %C contains the dataset name in each iteration.
W Execute for all workbooks in the project. %H contains the window name in each iteration.
WM Execute for all workbooks and matrixbooks in the project. %H contains the window name in each iteration.
WW Behaves the same as "W" but skips over any Excel books in the project.

See also other looping commands: for, loop, repeat.

-ef; Execute the given script for all objects in the current folder

Syntax doc -ef

Execute the given script for all objects of the specified kind in the current Project Explorer folder. Same as the -e option, but only the current Project Explorer folder will be considered.

Note: This assumes that the Project Explorer view mode is set to View Windows in Active Folder. If the view mode is set to View Windows in Active Folder & Subfolders, then this command will consider the active folder and subfolders.

-ffu; Force the column formula to update

Syntax doc -ffu

Force the all column formula in the project file to update no matter in what situation.

-gp state; Generate previews for earlier version graphs in Project Explorer

Minimum Origin Version Required: 2015 SR0

Syntax doc -gp state

Generate previews for earlier version graphs in Project Explorer so hovering over the graph icon will show tooltip view. If state = 0, generate previews for current folder, not recursive. If state = 1, generate previews for current and sub folders. If state = 2, generate previews for entire project.

-ha; hide all windows

Minimum Origin Version Required: 2019b

Hide all windows in the active folder. GUI equivalent is Window: Hide all Windows.

-l; Send an update message to all windows

Syntax: doc -l

Send an update message to all windows.

-log; Open the Audit Log dialog

Syntax: doc -log

Open the Audit Log dialog. Select Enable to track changes to the project. When first enabled, you will be prompted to establish an optional password for the Audit Log.

-log1 [password]; Enable the Audit Log for current project with an optional password

Syntax: doc -log1 [password]

Enable the Audit Log for current project with an optional password. If a password is set, you will need to enter the password when disabling auditing. This log can be viewed by anyone but can only be stopped by those who know the password.

-log0 [password]; Disable the Audit Log for current project

Syntax: doc -log0 [password]

Disable the Audit Log for current project. If a password has been set, you will need to enter the password when disabling auditing.

-lr flag; Control access to OC/LabTalk codes attached to OPJ

Minimum Origin Version Required: 2015 SR0

Syntax: doc -lr flag

Flag Description
16 Disable access to Code Builder's Project folder.

Note:

doc -lr 0; // turn off all flags

-m Origin_window_state; Control the display state

Syntax: doc -m Origin_window_state

These options control the display state of the Origin window:

0 Hide
1 Normal
2 Minimize
3 Maximize
4 Restore
5 Show

-mg Origin_modified_state; Get the modified state

Syntax: doc -mg Origin_modified_state

Get the modified state of current project and output into variable Origin_modified_state, Origin_modified_state = 1 if modified, 0 if not modified.

-ms; clear the modified state

Syntax: doc -ms

Clear the modified state for project and pages.

-n; Start new project

Syntax: doc -n

Execute the DocEnd macro (if defined). Close the current project. Read the ORGSYS.CNF file. Open a new project. The new project is defined by your settings under Preference: Options : [Open/Close] : 'Start New Project'. Do not open the New Workbook dialog (see -nt, below).

-nf; Add a new folder to Project Explorer

Syntax: doc -nf

Create a new folder directly off of the root folder in Project Explorer. The new folder will have the name Foldern where n is an integer corresponding to the order in which it was created.

-nt; Start new project, show New Workbook dialog if "on startup" is enabled

Syntax: doc -nt

Like the -n switch but show the New Workbook dialog if the dialog check box Show on startup and new project, is enabled.

-o projectName; Open a project

Syntax: doc -o projectName

Open a new Origin project, using the following steps:

  1. Execute the DocEnd macro (if defined). This will close any currently open project.
  2. Read the ORGSYS.CNF file and execute the DocBegin macro (if defined).
  3. Open the named project (Note: projectName must be a full path description, including the file extension).

-of objectName; Open a project in different directory

Syntax doc -of objectName

Execute the DocEnd macro (if defined). Close the current project. Read the ORGSYS.CNF file. Execute the DocBegin macro (if defined). Open the named project using the full path and name specified. If no path, then look first in the current directory, then in the software directory.

projectName must be a full path description, including the file extension. Look for projectName first in the current directory and then in the software directory.

-pda[d]; Apply Master Template page dimensions to other graph pages in the project

Syntax: doc -pda[d]

The Master Template must be active when the command is issued. The optional d dumps a list of affected graphs to the Messages Log.

Note, that this command cannot convert landscape-oriented pages to portrait or vice versa. To change page orientation, see the page -o command.

-pw; Supply password for modifying project

Syntax: doc -pw password

Provides Admin password set by doc -pwa (see next). Changes to project cannot be saved without password.

-pwa; Password protect against modifying project

Syntax: doc -pwa

Sets an Admin password for saving changes to the current project.

-pwd; Password protect against opening project

Syntax: doc -pwd

Opens a dialog to set or change the password for the current project. Password is required to reopen the OPJ.

-pwr [password]; Remove Admin password from project

Syntax: doc -pwr ;

If no password is specified, then you must first log in remove the password.

-pwta; List books/sheets with protection turned on

Syntax: doc -pwta;

-pwx; Logout of Admin mode

Syntax: doc -pwx;

Once logged out, no changes are permitted to anything related to protections.

-r newName; Rename the current project

Syntax: doc -r newName

Rename the current project to newName. Origin resets the path to your User Files Folder.

-rn newName; Rename the current project

Syntax: doc -rn

Reset the name of the current project to UNTITLED such that saving the project (e.g. File: Save) will open File: Save As.

-rr; Recover the range with empty UID data reference in the entire project

Syntax: doc -rr

Recover the ranges with empty UID data reference in the entire project.

-rri; Recover the range with empty UID data reference and inputs

Syntax: doc -rri

Recover the ranges with empty UID data reference, and also recover the inputs of operations in the entire project (it is not always reliable because it involves some guessing).

-rrit; Connect the table objects on graph pages for the whole project

Syntax: doc -rrit

Connect the table objects on graph pages for the whole project after loading it. You have to manually refresh graphs after this to see table objects.

-s; Turn off the save flag

Syntax: doc -s

Turn off the save flag so that no save prompt appears on exit.

-ss state; Control save prompt flag

Syntax: doc -ss state

Control save prompt flag. If state = 1, do not prompt to save on exit even when file is modified. If state = 0, restore to default (prompt to save if modified). The doc -ss 1 option turns off the save prompt for the Origin session unless a doc -ss 0 is executed, while the effect of doc -s ends when a project is (again) modified.

-t path templateFilename; Open the template file

Syntax: doc -t path templateFilename

Open the template file templateFilename. Use this command to open a template from any directory, but if no path is specified then Origin looks first in the User Files Folder and then in Origin EXE folder. You must specify the file extension.

-u; Set update flags

Syntax: doc -u

Set update flags for all layers in all windows.

-uw; Set update flags in current window only

Syntax: doc -uw

Set update flags for all layers in the current window only.

-wf; remove all cell or column formula/links/script

Minimum Origin Version Required: 2022b

Syntax: doc -wf [option]

Run this command, you can


All options are bit combination. For example, you can write the command as below:

doc -wf 3; ///wipe out all col formula & cell formula/link(Option =  "1"+"2"="3")
doc -wf; ///remove all formula, links and relevant script

-xw excelBookName; Convert internal Excel book into Origin workbook

Syntax: doc -xw excelBookName

Convert the internal Excel book into Origin workbook. If supply the name excelBookName, it will convert the specified Excel book, or, if the name not supplied, all the internal Excel books in the project, will be converted into Origin workbooks.

Examples:

The following script prints the contents of all graph windows in the project.

doc -e P print;

The next script rescales all layers in the project to show all data, sets each initial X axis scale value to zero, and types the window name and layer number of each to the Script window.

doc -e L 
{
     layer -a; 
      x1 = 0;
      type "Window: %H, layer number: $(page.active)";
};

The following script puts the name of the first worksheet into %A.

doc -e W 
{
      %A = %H; 
      break;
};

This script looks at all non-minimized windows and types its name and window type.

doc -e O {
   type = exist(%H);
   switch(type)
   {
   case 2:
      if(%H!page.extinfo) type %H is an Excel Workbook;
      else type %H is an Origin Workbook;
      break;
   case 3:
      type %H is a Graph window;
      break;
   case 4:
      type %H is a Matrixbook;
      break;
   case 11:
      type %H is a Layout page;
      break;
   }
}

See Also:

DocBegin, DocEnd