Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 2nd, 2006, 10:40 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default Jscript Excel PasteSpecial

Hi,

I'm trying to do some automation of Excel through Jscript, but I keep getting an error in regards to when I try to pastespecial (PasteSpecial method of Range class failed). Any help would be great...

<script type="text/javascript">
var objXl, ws;
function test()
{
    objXl = new ActiveXObject("Excel.Application");
    objXl.Visible = true; //set to TRUE for debugging
    objXl.WorkBooks.open(document.forms[0].tFile.value);
    ws = objXl.ActiveSheet;

    var xlPasteValues = -4163;
    var xlPasteSpecialOperationNone = -4142;
    var xlPasteFormulas = -4123;
    var total = ws.UsedRange.Rows.Count;

    ws.Range("C2").value = "=concatenate(A2,\" \",B2)";
    ws.Range("C2").Copy();
    ws.Range("C2:C"+total).Select();
// ws.PasteSpecial(); <- works but copies the formula
// ws.PasteSpecial(xlPasteValues,xlPasteSpecialOperat ionNone,false,false); <- doesn't work, but this is what I need to work...
}
</script>

 
Old June 11th, 2006, 09:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

The code shown at http://p2p.wrox.com/topic.asp?TOPIC_ID=33665 seems to have a few minor differences to yours, suggest you try them out and let us know if it works.





Similar Threads
Thread Thread Starter Forum Replies Last Post
JScript DumAss HTML Code Clinic 1 August 25th, 2004 02:46 AM
Using JScript with VBScript jwalborn Javascript How-To 4 October 13th, 2003 10:07 AM
PLEASE HELP! ACTIVEX in JScript stalker Javascript 2 August 15th, 2003 05:04 PM
JScript Des67 Javascript 1 July 28th, 2003 05:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.