4

私はこのコードを持っています:

<html>
  <script type="text/javascript">
    function test() {
      var Excel = new ActiveXObject("Excel.Application");
      Excel.Workbook.Open("teste.xlsx");
    }
  </script>

  <body>

    <form name="form1">
      <input type=button onClick="test();" value="Open File">
      <br><br>
    </form>

  </body>
</html>

したがって、主な問題は、このエラーが発生し続けることです。

On line 7 , Unable to get value of property Open
URL file:///C:/users/admin/desktop/test.hta
4

2 に答える 2

7

まず、スクリプトを本体の下部に移動してみてください。Excelまた、変数を表示するように設定する必要があります。そして、その行にタイプミスがありますExcel.Workbook.Open("teste.xlsx");(あるはずですWorkbooks)。以下はIEで私のために働いています。他のブラウザでは機能しないと思います。

<html>

  <body>

    <form name="form1">
      <input type=button onClick="test()" value="Open File">
      <br><br>
    </form>

    <script type="text/javascript">
      function test() {
        var Excel = new ActiveXObject("Excel.Application");
        Excel.Visible = true;
        Excel.Workbooks.Open("teste.xlsx");
      }
    </script>
  </body>
</html>
于 2013-03-06T12:17:17.753 に答える
1

これはIE11で機能し、インターネットオプションですべてのActiveXコントロールを有効にする必要があります。これにより、Excelが開き、シート名に記載されているとおりのシートが開きます。

<form name="form1">
  <input type=button onClick="test()" value="Open File">
  <br><br>
</form>

<script type="text/javascript">
  function test() 
  {  
    var Excel = new ActiveXObject("Excel.Application");  
    Excel.Visible = true; Excel.Workbooks.open("c:\\jeba\\sample.xlsx");  
    var excel_sheet = Excel.Worksheets("sheetname_1");  
    excel_sheet.activate();  
  }   
</script>

于 2019-11-21T20:17:25.490 に答える