Advanced Search

Results 1 to 2 of 2

Thread: Expected ';' Error when trying to run excel macro

  1. #1
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Expected ';' Error when trying to run excel macro

    I am writing a web page to serve as a front to access an excel workbook that generates a config file for some hardware. Currently this is just me testing the concept and getting familiar with how jscript automates excel.

    My problem is when I try to run the macro, I keep getting an "Expected ';' error" at the same line as my oXL.run(). As far as I am aware the syntax is correct, and the same oXL.run("book!module.macro") works in a second script I wrote that calls a diff macro in a diff workbook. I have already fixed the .dlls on my PC and checked IE settings, but what confuses me is why this won't work yet the other jscript runs just fine.

    Code:
    <!DOCTYPE html>
    <html lang="en">
    	
    
    <body>
    <SCRIPT LANGUAGE="VBScript">
    
    </SCRIPT>
    
    <SCRIPT LANGUAGE="JScript"> 
    function AutomateExcel(store,direct,MdfFloor,MdfSW,Include)
    {
    
       // Start Excel and get Application object.
          var oXL = new ActiveXObject("Excel.Application");
          var filename = "D:\\Profiles\\ngwx36\\Desktop\\test.xlsm"; 
          oXL.Visible = true;
          
       // Open Staging Workbook
          var oWB = oXL.Workbooks.Add(filename);
        
             
       // Place vars from input in correct cell
          oWB.Sheets("Instructions").Cells(1, 5).Value = store;
          oWB.Sheets("Instructions").Cells(2,5).Value = direct;
          oWB.Sheets("SWInventory").Cells(3,2).Value = MdfFloor;
          oWB.Sheets("SWInventory").Cells(3,6).Value = MdfSW;
          
       //checks to see if 3rd MDF needs to be included
          if (Include == "Yes"){
          	oWB.Sheets("SWInventory").Cells(5,2).Value = "Included";
          }
          
       //fill 2 IDFs in to test atm
          oWB.Sheets("SWInventory").Cells(7,2).Value = "1";
          oWB.Sheets("SWInventory").Cells(7,3).Value = "1";
          oWB.Sheets("SWInventory").Cells(7,4).Value = "SW01";
          oWB.Sheets("SWInventory").Cells(7,6).Value = "EX2200C";
          oWB.Sheets("SWInventory").Cells(8,2).Value = "2";
          oWB.Sheets("SWInventory").Cells(8,3).Value = "2";
          oWB.Sheets("SWInventory").Cells(8,4).Value = "SW02";
          oWB.Sheets("SWInventory").Cells(8,6).Value = "EX2200C";
          
         oXL.Run("test.xlsm!Module1.makeconfigs");
        
     
    }
       
    </SCRIPT>
    <Form Name=Input>
    <p>
              <label>Store Name</label>
              <input type = "text"
                     name= "StoreName"
                     value = "" />
    </p>
    <p>
              <label>File Directory</label>
              <input type = "text"
                     name= "FilePath"
                     value = "" />
    </p>
    <p>
              <label>MDF Floor #</label>
              <input type = "text"
                     name= "MdfFloor"
                     value = "" />
    </p>
    <p>
              <label>MDF Type</label>
              <input type = "text"
                     name= "MdfType"
                     value = "Enter MDF SW TYpe" />
    </p>
    <p>
              <label>MDF Include</label>
              <input type = "text"
                     name= "MdfInc"
                     value = "3rd MDF Yes or No?" />
    </p>
    
    </form>
    <P><INPUT id=button1 type=button value="Start Excel" 
              onclick="AutomateExcel Input.StoreName.Value,Input.FilePath.Value,Input.MdfFloor.Value,Input.MdfType.value,Input.MdfInc.Value">
    </P>	
    
    </body>
    </html>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,640
    Thanks
    42
    Thanked 2,896 Times in 2,868 Posts
    Blog Entries
    12

    Default

    I'm not familiar with what you're doing. But in ordinary javascript, this:

    Code:
    onclick="AutomateExcel Input.StoreName.Value,Input.FilePath.Value,Input.MdfFloor.Value,Input.MdfType.value,Input.MdfInc.Value"
    should be:

    Code:
    onclick="AutomateExcel(Input.StoreName.value,Input.FilePath.value,Input.MdfFloor.value,Input.MdfType.value,Input.MdfInc.value);"
    And constructs like:

    Code:
    Input.MdfType.value
    are safer when written out fully as:

    Code:
    document.forms.Input.MdfType.value
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Object Expected Error
    By justuferns in forum ASP
    Replies: 1
    Last Post: 05-21-2011, 05:07 AM
  2. Error: Expected ;
    By rhodarose in forum PHP
    Replies: 2
    Last Post: 12-15-2010, 01:14 AM
  3. Replies: 0
    Last Post: 07-15-2010, 01:10 AM
  4. error: object expected
    By fazlionline in forum Other
    Replies: 2
    Last Post: 04-07-2009, 04:16 AM
  5. expected ';' error?
    By voobass in forum JavaScript
    Replies: 8
    Last Post: 11-25-2006, 07:42 PM

Bookmarks

Posting Permissions

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