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
 Activate sheet by range
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

AKazak

Russia
1228 Posts

Posted - 07/15/2022 :  01:44:57 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 2022b (64-bit) SR1 9.9.5.171
Windows 7 Pro SP1 x64

Greetings!

I have a range object with few columns on a specified sheet.
How do I activate the sheet from the range object?
How do I select the range?

Thank you.

---
Andrey

YimingChen

1684 Posts

Posted - 07/15/2022 :  10:01:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you have one column in the range, you can try the sample script below:

range r1 = [book1]1!1;
win -a %(r1.GetPage()$); // activate the page
range rwks = r1.GetLayer()$;
page.active$ = rwks.name$; // activate the sheet
wks.colSel(Colnum(r1), 1); // select the column


If you have multiple columns, you may need to parse the range string to get the columns. The range string can be obtained by:

String strRange = %(r1);


James
Go to Top of Page

AKazak

Russia
1228 Posts

Posted - 07/15/2022 :  10:55:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by YimingChen

If you have one column in the range, you can try the sample script below:

range r1 = [book1]1!1;
win -a %(r1.GetPage()$); // activate the page
range rwks = r1.GetLayer()$;
page.active$ = rwks.name$; // activate the sheet
wks.colSel(Colnum(r1), 1); // select the column


If you have multiple columns, you may need to parse the range string to get the columns. The range string can be obtained by:

String strRange = %(r1);


James



Dear James,

Got it.

What do you mean by parsing the range string to get the columns?

---
Andrey
Go to Top of Page

YimingChen

1684 Posts

Posted - 07/15/2022 :  11:25:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
For example, if you have multiple columns in a range. You need to get the start and end columns, you may use:

range rd = [Book2]Sheet3!5:10;
String strRange = %(rd);
int colStart = value(between(strRange$,"!",":")$);
int colEnd = value(GetToken(strRange$,2,":")$);
colStart=;
colEnd=;


James

Edited by - YimingChen on 07/15/2022 11:25:39 AM
Go to Top of Page

AKazak

Russia
1228 Posts

Posted - 07/15/2022 :  11:28:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by YimingChen

For example, if you have multiple columns in a range. You need to get the start and end columns, you may use:

range rd = [Book2]Sheet3!5:10;
String strRange = %(rd);
int colStart = value(between(strRange$,"!",":")$);
int colEnd = value(GetToken(strRange$,2,":")$);
colStart=;
colEnd=;


James



I see.
Where do I pass colStart and colEnd values?

---
Andrey
Go to Top of Page

YimingChen

1684 Posts

Posted - 07/15/2022 :  12:22:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Pass the column index from colStart to colEnd into the wks.colSel() function.
Go to Top of Page

AKazak

Russia
1228 Posts

Posted - 07/18/2022 :  12:25:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by YimingChen

Pass the column index from colStart to colEnd into the wks.colSel() function.



Got it!
Thanks.

---
Andrey
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