Calling .Move() From Javascript

S

SharonGordon

Hi! I am building a spreadsheet using Javascript and need to reorder
some of the sheets.

The example mentioned in the Excel Help file shows exactly what I want
to do:

Move Method Example
This example moves Sheet1 after Sheet3 in the active workbook.
Worksheets("Sheet1").Move after:=Worksheets("Sheet3")

Can someone tell me how to translate this into Javascript?

Many thanks!
Sharon
 
C

Colo

Hi Sharon,

Please let us have the code how you handle Excel via JavaScript?

Using wshshell? execScript? or location.href='Book1.xls'; ?
 
C

Colo

Or why not use VbScript??
Here is a sample that I wrote for you.
Calling VbScript from JavaScript.

<html>
<head>
<script language="JavaScript"><!--
function excel()
{
execScript("ControlExcel",'VBScript');
}
// --></script>
<script language="VBScript"><!--
Sub ControlExcel()
Dim XL, WB, i
Set XL = CreateObject("Excel.Application")
XL.Visible =True
Set WB = XL.Workbooks.Add
For i = 1 to 3
XL.Worksheets.Add
Next
Msgbox WB.Sheets(WB.Sheets.Count).name
WB.Sheets(1).Select
WB.Sheets(1).Move ,WB.Sheets(WB.Sheets.Count)
End Sub
--></script>

<a href="javascript:excel()">Open text.xls via Excel</a>
</head>
</html>


--
Kind Regards
Colo
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Colo of 'The Road of The Cell Masters' :)

URL:http://www.interq.or.jp/sun/puremis/colo/CellMastersLink.htm
mailto:[email protected]

/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
 
C

Colo

Sorry please use this code.

<html>
<head>
<script language="JavaScript"><!--
function excel()
{
execScript("ControlExcel",'VBScript');
}
// --></script>
<script language="VBScript"><!--
Sub ControlExcel()
Dim XL, WB, i
Set XL = CreateObject("Excel.Application")
XL.Visible =True
Set WB = XL.Workbooks.Add
For i = 1 to 3
XL.Worksheets.Add
Next
MSGBOX "Move worksheet(1) to the end"
WB.Sheets(1).Move ,WB.Sheets(WB.Sheets.Count)
End Sub
--></script>

<a href="javascript:excel()">Create an Excel Instance and handle via
VBScript</a>
</head>
</html>


--
Kind Regards
Colo
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Colo of 'The Road of The Cell Masters' :)

URL:http://www.interq.or.jp/sun/puremis/colo/CellMastersLink.htm
mailto:[email protected]

/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
 
S

SharonGordon

Colo,

Hi! I am actually embedding Javascript in some ColdFusion code.

And, I was able to get the following to work finally:
oWB.Sheets("Sheet1").Move(null,oWB.Sheets(oWB.Sheets.Count));

Many thanks for your help!

Sharon
 
Top