Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with JavaScript-VBScript and Excel programming file

    Hi all, I am having a problem with the following code. The font is red is where the error is coming. When I type both the lines together, it says 'Expected ;' but they work independently.

    can you guys figure out the problem? I have been breaking my head on it all day!!



    <HTML>
    <BODY>
    Press the button to start Excel and display quarterly data.

    <SCRIPT LANGUAGE="VBScript">


    Function RemoveSR(oXL)
    ' Create an array to set multiple values at once.
    dim x
    dim y
    x=1
    y=1

    Do Until oXL.Cells(x,y).Value = ""
    x = x + 1
    loop

    Dim saNames_1(9999, 18)
    dim arr_xcount

    arr_xcount=1

    for rx = 1 to x

    if oXL.Cells(rx, 8) <> "Service Request" then

    for ry = 1 to 18
    saNames_1(arr_xcount-1, ry-1) = oXL.Cells(rx, ry).Value

    next


    arr_xcount = arr_xcount + 1

    end if




    next

    RemoveSR = saNames_1
    End Function

    Function CreateNamesArray(oXL)
    ' Create an array to set multiple values at once.
    dim x
    dim y
    x=1
    y=1
    Do Until oXL.Cells(x,y).Value = ""
    x = x + 1
    loop

    Dim saNames(9999, 18)
    dim arr_xcount

    arr_xcount=1

    for rx = 1 to x

    if oXL.Cells(rx, 8) = "Service Request" then

    for ry = 1 to 18
    saNames(arr_xcount-1, ry-1) = oXL.Cells(rx, ry).Value
    next

    arr_xcount = arr_xcount + 1

    end if



    next

    CreateNamesArray = saNames
    End Function







    </SCRIPT>


    <SCRIPT LANGUAGE="JScript">
    function AutomateExcel()
    {

    // Start Excel and get Application object.
    var oXL = new ActiveXObject("Excel.Application");
    var oWB1=oXL.Workbooks.Open("C:\\Documents and Settings\\T_SHAHMA\\Desktop\\work_folder\\060607b.csv");
    var oSheet=oWB1.ActiveSheet;
    oSheet.PageSetup.Zoom=90;

    oSheet.Range("A2","CM3052").Font.Bold=true;

    var oSheet2=oWB1.WorkSheets.add;
    oSheet2.Name="New Sheet";



    oSheet.Activate;


    oSheet2.Range("A2", "P9999").Value = CreateNamesArray(oXL);
    oSheet2.Name="Service Requests";


    var oSheet3=oWB1.WorkSheets.add;
    oSheet3.Name="All Service Requests";






    oSheet.Activate;
    oSheet3.Range("A1", "R9999").Value = RemoveSR(oXL);

    oSheet3.Name="All Service Requests";


    oXL.Visible = true;
    oXL.UserControl = true;






    }

    </SCRIPT>
    <P><INPUT id=button1 type=button value="Start Excel" onclick="AutomateExcel"></P>
    </BODY>
    </HTML>

  • #2
    New Coder
    Join Date
    Dec 2006
    Posts
    80
    Thanks
    1
    Thanked 0 Times in 0 Posts
    oSheet.Activate;
    oSheet3.Range("A1", "R9999").Value = RemoveSR(oXL);
    What is RemoveSR(oXL)? Is the error occurring at this line, or if RemoveSR() is a javascript function, is the error occurring within that? Also, have you checked the value of oXL to make sure its not null/empty, or a malformed string/integer?

    Also, don't know if this is a typo:

    <P><INPUT id=button1 type=button value="Start Excel" onclick="AutomateExcel()"></P>


    Joe


    Last edited by LFCFan; 06-08-2007 at 01:12 PM.
    http://www.Kanotix.com --My OS of choice, the best hardware detection on the planet!-
    http://distrowatch.com -Linux is the future-
    http://www.packetstormsecurity.org -Security Gurus-

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    RemoveSR(oXL) is a function in VBscript

    I am calling RemoveSR function and passing it the excel application as parameter.

    It is very similar to the manner in which ChangeNamesArry function is called and it works!

    I tried everything by renaming variables but it still asks for the semicolon.

    This is the line.


    oSheet3.Range("A1", "R9999").Value = RemoveSR(oXL);



    I don thtink oXL is null as it works for a similar fucntion before i call RemoveSR...that is ChangeNames Array.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •