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
 Copy/Paste
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Tryphon

36 Posts

Posted - 06/17/2015 :  4:38:42 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Version: Origin 8.0
Programming : Labtalk

Hello,

I want to copy an entire Worksheet into an Excel sheet including the Long Name, Units and Comments rows.

What is working now : with the mouse, I can select the entire worksheet clicking the empty grey cell at (0,0) position, copy it and paste it in an Excel sheet created by the "New Excel" button.

Therefore, an internal command exists in Origin that is able to copy ALL the worksheet in one shot

I want to do that automatically using Labtalk.

The following code works partially :


win -a MySheet;
worksheet -s 1 0 $(wks.ncols) 0;
menu -e 57634; //The copy command in the Edit menu
win -a MyExcelSheet;
excel.runrange(Sheet1,A4);
excel.run(PasteData);


where PasteData is an Excel macro recorded in MyExcelSheet:

Sub PasteData()
ActiveSheet.Paste
End Sub

Of course this code cannot select the Long Name, Units and Comments rows.

How to do this with Labtalk ?

Thank you.

SeanMao

China
288 Posts

Posted - 06/17/2015 :  10:15:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You only need to modify one line:


menu -e 38799; // Copy(including Label Rows) option


Regards!

Sean

OriginLab Tech. Service
Go to Top of Page

Tryphon

36 Posts

Posted - 06/18/2015 :  08:20:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Thank you for the answer.

menu -e 38799 did not help or I do not understand how to use it.

I did a mistake in my initial post :

"Therefore, an internal command exists in Origin that is able to copy select ALL the worksheet in one shot"

before copying.

Another idea ?

Thank you.
Go to Top of Page

SeanMao

China
288 Posts

Posted - 06/18/2015 :  10:01:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The answer to your concern is yes, Origin can copy entire worksheet including column label rows.

Menu id 38799 corresponds to menu item Copy (including label rows) as shown below:



What you have used previously is menu 57634 corresponding to Copy only.

To know the menu id of a menu item, you can hold Ctrl + Shift key and click on that item, the menu id will be output to Script Window.

I mean you should replace line menu -e 57634 with line menu -e 38799 in former post.

I run the following script as you have written:


win -a MySheet;
worksheet -s 1 0 $(wks.ncols) 0;
menu -e 38799; //The copy command in the Edit menu
win -a MyExcelSheet;
excel.runrange(Sheet1,A4);
excel.run(PasteData);


Below is the result I got:




It ran exactly as you wanted. I am not sure what went wrong on your side.

Regards!

Sean

Edited by - SeanMao on 06/18/2015 10:04:11 PM
Go to Top of Page

Tryphon

36 Posts

Posted - 06/19/2015 :  05:06:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Maybe, what went wrong is related to the version? I use the version 8.0724 and I cannot see the "Copy (including labels rows)" command in the edit menu.

Secondly, when I use the command

worksheet -s 1 0 $(wks.ncols) 0;

it produces this selection :



but not the selection in your example.
Go to Top of Page

SeanMao

China
288 Posts

Posted - 06/19/2015 :  05:10:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I guess that's it.

My Origin 8 version is OriginPro 8.0 SR6 version v8.0988.

You should update your Origin 8 to latest patch.

Regards!

Sean
Go to Top of Page

Tryphon

36 Posts

Posted - 06/19/2015 :  08:32:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I need to ask the administrator for this update.

Thank you.
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