Controlling Excel via JScript 
Author Message
 Controlling Excel via JScript

Hi Dave, I've done a bit of report creation and other manipulation of Excel
in WSH, let me know what you need to know (what  you're having trouble with)
and I'll try to post a relevant example.

Richard


Quote:
> All, I am writing a script and creating an ActiveX control
> to launch excel on user's desktop and do some copy paste
> special functions.  I am having a heck of a time trying to
> find the correct syntax for the Excel document model for
> use with Jscript.  Does anyone know reference materials on
> the MS site or a good book to use as reference?

> Thank you in advance.
> Dave



Wed, 08 Sep 2004 04:05:30 GMT  
 Controlling Excel via JScript
Hi Richard,  Thank you for the reply... Here is what I am
trying to do and the following code.  I am copying the
contents of a web page and opening Excel locally.  I then
paste the contents of the web site into excel.  I can get
the contents into excel but it comes through with
hyperlinks etc.  I would like to add an additional
copy/paste but using the Paste Special function with
the "paste as formulas" parameter which would then remove
the hyperlinks and formatting.  I just can't get the
syntax and can't find any reference.

Here is my script:

    <SCRIPT language="JavaScript">
        function bringToExcel()
        {

         this.document.execCommand("SelectAll", false);
         this.document.execCommand("Copy", true);
         this.document.execCommand("UnSelect", false);

         // Start Excel and get application object.
         var oXL = new ActiveXObject("Excel.Application");
         oXL.Visible = true;

         // Get a new workbook.
         var oWB = oXL.Workbooks.Add();
         var oSheet = oWB.ActiveSheet;
         oSheet.Paste();
         oXL.Selection.Copy();
         oSheet.Paste();
         //  oXL.Selection.PasteSpecial
("xlFormulas,xlNone,False,False");  Can't get the syntaX!!
         oXL.Visible = true;
         oXL.UserControl = true;
         }
    </SCRIPT>
Thanks again
Dave

Quote:
>-----Original Message-----
>Hi Dave, I've done a bit of report creation and other

manipulation of Excel
Quote:
>in WSH, let me know what you need to know (what  you're

having trouble with)
Quote:
>and I'll try to post a relevant example.

>Richard



>> All, I am writing a script and creating an ActiveX
control
>> to launch excel on user's desktop and do some copy paste
>> special functions.  I am having a heck of a time trying
to
>> find the correct syntax for the Excel document model for
>> use with Jscript.  Does anyone know reference materials
on
>> the MS site or a good book to use as reference?

>> Thank you in advance.
>> Dave

>.



Wed, 08 Sep 2004 04:22:10 GMT  
 Controlling Excel via JScript
There's a lot of stuff at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnof...
ml/vsofficedev.asp


Quote:
> All, I am writing a script and creating an ActiveX control
> to launch excel on user's desktop and do some copy paste
> special functions.  I am having a heck of a time trying to
> find the correct syntax for the Excel document model for
> use with Jscript.  Does anyone know reference materials on
> the MS site or a good book to use as reference?

> Thank you in advance.
> Dave



Fri, 10 Sep 2004 10:47:56 GMT  
 Controlling Excel via JScript
I think what you want for the syntax of PasteSpecial is this:
// first define xlPasteFormulas - the constant that is passed to the method:

var xlPasteFormulas = -4123

// I got that value by looking in the Excel Object browser
// from any XL worksheet Alt-F11 then in the VBA window, F2

// next use it to call PasteSpecial
// also, use false, not False, unless you
// have separately defined a variable
// like var False = false;

oXL.Selection.PasteSpecial(xlPasteFormulas, false, false);

Let me know if this doesn't work for you,
Richard


Quote:
> Hi Richard,  Thank you for the reply... Here is what I am
> trying to do and the following code.  I am copying the
> contents of a web page and opening Excel locally.  I then
> paste the contents of the web site into excel.  I can get
> the contents into excel but it comes through with
> hyperlinks etc.  I would like to add an additional
> copy/paste but using the Paste Special function with
> the "paste as formulas" parameter which would then remove
> the hyperlinks and formatting.  I just can't get the
> syntax and can't find any reference.

> Here is my script:

>     <SCRIPT language="JavaScript">
> function bringToExcel()
> {

> this.document.execCommand("SelectAll", false);
>   this.document.execCommand("Copy", true);
>   this.document.execCommand("UnSelect", false);

>   // Start Excel and get application object.
> var oXL = new ActiveXObject("Excel.Application");
> oXL.Visible = true;

> // Get a new workbook.
> var oWB = oXL.Workbooks.Add();
> var oSheet = oWB.ActiveSheet;
> oSheet.Paste();
> oXL.Selection.Copy();
> oSheet.Paste();
>          //  oXL.Selection.PasteSpecial
> ("xlFormulas,xlNone,False,False");  Can't get the syntaX!!
> oXL.Visible = true;
> oXL.UserControl = true;
> }
>     </SCRIPT>
> Thanks again
> Dave



Fri, 10 Sep 2004 23:25:16 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. html to excel via JScript

2. detection of currently installed ActiveX controls via jscript

3. filename error when trying to open a report into excel via vbscript

4. export SQL to Excel via ASP

5. Setting "Subject" in Excel via vbs

6. Manipulating Excel via VBS

7. Link to Excel file via Web

8. Saving Data from Excel via IE into SQL

9. Launch HTML page within Excel via VBScript

10. inputs via vbs in Excel is very, very slow when partsum assistent is used

11. printing an excel value on a web page via vbscript

12. Problems to start Excel within IE - VBScript via CreateObject

 

 
Powered by phpBB® Forum Software