2.2.3.57 wmove_sheet

Brief Information

Move the specified worksheet to the destination workbook

Additional Information

Minimum Origin Version Required: 8.5 SR0

Command Line Usage

wmove_sheet source:=2! target:=<new> name:=abc$;

wmove_sheet source:=1! target:=[book1] name:=wksname$ index:=2;

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Source Worksheet source

Input

Worksheet

none
Specify the source worksheet to be moved
Target Workbook target

Output

WorksheetPage

<new>
Specify the destination workbook into which the source worksheet is moved

See the syntax here.

Name of Moved Sheet name

Output

string

name$
Specify a string variable name to store the worksheet name to after moving. It is inaccessible from GUI, and is useful when the moved worksheet name is changed.
Index index

Input

int

0
Specify the moved worksheet’s index in the destination workbook.

Description

This X-function is used to move the specified worksheet to the destination workbook. If a plot is created from the source worksheet, the plot will not be changed or removed when moving the worksheet.

Examples

The following scripts show you an example of moving a worksheet to the destination workbook, using the wmove_sheet X-function.

doc -s;
doc -n;
string path$ = system.path.program$ + "Samples\Import and Export\";
string fn1$ = path$ + "F1.dat";
string fn2$ = path$ + "F2.dat";
string fn3$ = path$ + "F3.dat";
string fn$=fn1$ + char(10)$ + fn2$ + char(10)$ + fn3$;
impasc fname:=fn$ 
options.ImpMode:=4                   // start with a new book 
options.Names.FNameToSht:=0          // turn off rename sheet to file name
options.Names.FNameToBk:=0;          // turn off rename book to file name 
newbook name:="move_destination" sheet:=3;
// move the first worksheet in Book1 to be the second worksheet of the "move_destination" workbook
wmove_sheet source:=[Book1]1! target:=[move_destination] name:=wksname$ index:=2;           
wksname$=; 
// should return Sheet4, 
// which shows that the moved sheet name has been changed from "Sheet1" to "Sheet4"
// since there already was a "Sheet1" in the destination workbook