ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling .Move() From Javascript (https://www.excelbanter.com/excel-programming/284922-calling-move-javascript.html)

SharonGordon

Calling .Move() From Javascript
 
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

Colo[_8_]

Calling .Move() From Javascript
 

Hi Sharon,

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

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


---
~~ Message posted from http://www.ExcelForum.com/


Colo

Calling .Move() From Javascript
 
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/...astersLink.htm


/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



"SharonGordon" wrote in message
m...
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



Colo

Calling .Move() From Javascript
 
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/...astersLink.htm


/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


"SharonGordon" wrote in message
m...
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



SharonGordon

Calling .Move() From Javascript
 
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.Shee ts.Count));

Many thanks for your help!

Sharon


All times are GMT +1. The time now is 09:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com