on 07-11-2007 8:42 PM
Hi All,
We have a Macro. I am opening a excel window with the data from a BSP. The macro should be automatically applied to Excel. I am writing JavaScript in a BSP and please find the code below. It opens data in a Excel window but the macro is not getting applied automatically. Any Suggestions?
function export_to_excel()
{
//cadrDetails = document.getElementById("cadrDetails");
var oExcel = new ActiveXObject("Excel.Application");
oBook = oExcel.Workbooks.Add("C:/\Program Files/\Microsoft Office/\Templates/\DPS_CAD.xlt");
//oSheet = oBook.Worksheets(1);
oSheet = oExcel.Workbooks(1).Sheets(1);
oSheet = oExcel.Workbooks(1).Sheets("Sheet1");
var rowSpanCells = new Array(cadrDetails.rows.length+1);
// Create table with actual rows and columns.
// HTML hides those rows/cols impacted by row/colspan
for (var y=0;y<cadrDetails.rows.length1;y+) {
rowSpanCells[y] = new Array(cadrDetails.rows(0).cells.length + 1);
}
excelRow = 1;
excelCol = 1;
for (var y=0;y<cadrDetails.rows.length;y+,excelRow+)
{
excelCol = 1;
for (var x=0;x<cadrDetails.rows(y).cells.length;x++)
{
setExcelText(oSheet, rowSpanCells, cadrDetails.rows(y).cells(x));
}
}
oSheet.Columns.AutoFit;
oSheet.Activate;
oExcel.Visible = true;
//oExcel.UserControl = true;
}
Thanks,
Naga
Look at the below excel, it has macro, like sum. It will help you..
<%@page language="abap"%>
<html>
<head>
</head>
<body>
<object id="msx" style="width:100%;height:300px;margin-top:50px"
classid="clsid:0002E510-0000-0000-C000-000000000046">
<param name="DisplayTitleBar" value="false"/>
<param name="HTMLData" value=""/>
</object>
<script type="text/javascript">
layout_sheet = document.all("msx");
layout_sheet.Cells(1,5) = 'Test mit einzelner Zelle';
msx.range('F1').value = 'F1';
range = layout_sheet.Range(layout_sheet.Cells(1,1),layout_sheet.Cells(1,4));
record = "Jahr;Januar;Februar;März";
range.ParseText(record, ';');
range = layout_sheet.Range(layout_sheet.Cells(2,1),layout_sheet.Cells(2,4));
range.value = [ 2006, '15', '17', '19' ];
msx.range('a3:d3').value = [ 2007, 33, 15, 13 ];
msx.range('a4:d4').value = [ 'Summen', '=SUM(B2:B3)', '=SUM(C2:C3)', '=SUM(D2:D3)' ];
msx.range('b2').NumberFormat = '####.00';
msx.range('b2').Interior.Color = 'red';
msx.range('c1:d1').Font.Name = 'Courier';
msx.range('c1:d1').Font.Color = 'blue';
msx.range('c1:d1').Font.Size = 12;
msx.range('c1:d1').Font.Bold = 1;
layout_sheet.Cells.AutoFitColumns();
</script>
</body>
</html>
*Reward each useful answer
Raja T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raja,
Thanks for your quick reply. I have a macro which is coded using VB is stored @ "C:/\Program Files/\Microsoft Office/\Templates/\DPS_CAD.xlt". I have to enable this macro automatically when i open excel using BSP. I think that i need to change the JavaScript so that it will take the macro file automatically and apply it.
Thanks,
Naga
hi,
chk this blog..
/people/thomas.jung3/blog/2005/02/23/bsp-and-microsoft-excel--learning-to-live-together-part-2
thanks
jaideep
*reward points if useful..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.