| T O P I C R E V I E W |
| alex_eagle |
Posted - 07/25/2003 : 04:02:15 AM I want to check for empty worksheets in a folder and delete them ? How is this done best with a Labtalk Script. I use Origin 7 Thanks
|
| 1 L A T E S T R E P L I E S (Newest First) |
| rlewis |
Posted - 07/25/2003 : 09:26:05 AM Compile and link the OriginC functions below then issue the command DestroyEmptyWorksheets() ... it works for me ...
void WksDeleteIfEmpty(string WksName) { /* Deletes a named Worksheet if it is empty */ Worksheet Wks; if (Wks.Attach(WksName)) { if(Is_Worksheet_Empty(WksName)==1) { Wks.Destroy(); return; } } }
int Is_Worksheet_Empty(string WksName) { /* Determines whether a named worksheet is empty. returns 1 (Worksheet empty) 0 (Worksheet not empty) -1 (Invalid Worksheet, WksName) */ Worksheet Wks; if (Wks.Attach(WksName)) { int LowRange, HighRange; foreach (Column WksColm in Wks.Columns) { WksColm.GetRange(LowRange, HighRange); if(HighRange>-1) return (0); } return (1); } return (-1); }
void DestroyEmptyWorksheets(void) { /* Deletes all empty worksheet in project .. */ Collection <WorksheetPage> wPg; wPg=Project.WorksheetPages; // All Worksheets in a project foreach (WorksheetPage wksItem in wPg) { WksDeleteIfEmpty(wksItem.GetName()); } } |
|
|