Other Workbook Operations
Obtain the workbook path
Open workbook
try
{
//Any current unsaved project changes are discarded, any objects
//held from the previous workbook may be corrupt. If data is to be
//transferred between workbooks hold the raw data in the script.
Toolbox.OpenWorkbook(@"C:\TestData\WorkbookToOpen.wwx");
Toolbox.Log("Workbook Opened");
}
catch (ScriptingException e)
{
Toolbox.Log(string.Format(
"Failed to open workbook with error: {0}",
e.Message),
LogLevel.Error);
}
New workbook
try
{
//Any current unsaved project changes are discarded, any objects
//held from the previous workbook may be corrupt. If data is to be
//transferred between workbooks hold the raw data in the script.
//This can also be used for releasing a previously opened workbook for moving.
Toolbox.NewWorkbook();
Toolbox.Log("Empty workbook creation successful");
}
catch (ScriptingException e)
{
Toolbox.Log(string.Format(
"Failed to create new workbook with error: {0}",
e.Message),
LogLevel.Error);
}
Save workbook
try
{
// The workbook cannot be temporary when this instruction is called.
Toolbox.Save();
Toolbox.Log("Workbook saved");
}
catch (ScriptingException e)
{
Toolbox.Log(string.Format(
"Failed to save workbook with error: {0}",
e.Message),
LogLevel.Error);
}
Save as workbook
try
{
Toolbox.SaveAs(@"C:\TestData\firstSave.wwx");
Toolbox.Log("Workbook saved");
}
catch (ScriptingException e)
{
Toolbox.Log(string.Format(
"Failed to save workbook with error: {0}",
e.Message),
LogLevel.Error);
}