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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Exporting all worksheets in active workbook

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
KMnO4aq Posted - 12/01/2014 : 11:41:46 AM
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 8.5.0
Operating System: Windows XP running on Parallels on my Mac


I am trying to export all of the worksheets in my active workbook to a specific directory. I have tried:

fdlog.openpath(B); // choose directory
doc -e W {save -w %H %B%H.txt};

But this only saves the first worksheet in each workbook. Any ideas?
1   L A T E S T    R E P L I E S    (Newest First)
cdrozdowski111 Posted - 12/02/2014 : 07:55:15 AM
Here is some code that saves every worksheet in the active workbook. It is much more complex but is also more robust (better folder dialog, error checking, etc)

int count;
doc -cw;	// Count the number of pages in project
if (count == 0)	// Make sure there is at least one
{
	// Output message and stop script
	type "There are no workbooks in project.";
	return;
}

string sPageName$ = page.name$;	// Get the short name of the active page (window)

if (exist(%(page.name$), 2) != 2)	// Make sure sure active page is a workbook.
{
	// Output message and stop script
	type "Current Window is not a workbook.";
	return;
}

string sPath$;
dlgPath -sb path:=sPath title:="Choose a Folder" showfiles:=0;	// This X-function is better than fdlog. It has more options if you are interested.
if (sPath.GetLength() == 0)	// If user clicked Cancel button, sPath$ will be empty.
{
	// Output message and stop script
	type "Operation Cancelled";
	return;
}

// User selected a folder, so continue script
for (int ii = 1; ii <= page.nlayers; ii++)	// Loop through every layer (worksheet) in active page (workbook).
{
	page.active = ii; // Activate layer (worksheet).
	string sFile$ = "%(sPath$)\%(page.name$)%(layer.name$).txt";	// Create full path to the file name to save the worksheet.
																 	// The "layer" variable is an object that represents the
																	// currently active layer (worksheet).
	save -w %(layer.name$) "%(sFile$)";	// Save the worksheet into the file.
}

type "All worksheets in active workbook exported";


Note: If you are so inclined, the expASC X-function (http://www.originlab.com/doc/X-Function/ref/expASC) offers much more control over your data export than the save command.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000