The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Searching for empty worksheets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

alex_eagle

Austria
36 Posts

Posted - 07/25/2003 :  04:02:15 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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


rlewis

Canada
253 Posts

Posted - 07/25/2003 :  09:26:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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());
}
}
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000