SCRIPT438:Object不支持此属性或方法:'Document.GetElementsByName'

时间:2016-06-29 09:30:01

标签: html vbscript

我有以下代码,经过一些调试后,我遇到了一堵砖墙。调试时会抛出错误

SCRIPT438:Object不支持此属性或方法:'Document.GetElementsByName'

执行提交按钮时,它会加载电子表格,但由于错误不知道要写什么,然后才能完成操作。

代码低于

<! DOCTYPE html>
<Html>
<Head>
<meta http-equiv="x-ua-compatible" content="IE=9">
<script language="vbscript" type="text/vbscript">
Sub Divert ()
    Dim iRow
    Set objExcel = CreateObject ("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open ("G:\Bournemouth\CorporateShared\General Insurance\GI complaint Team\CRU Diverted\diverted.xlsx")
    objExcel.Application.Visible = True
    ObjWorkbook.Windows (1).Visible = True
    Set XlSheet =objWorkbook.Sheets (1)
    XlSheet.Activate

    iRow = 1
    With objExcel
    Do while .Cells (iRow, 1).value <> ""
    .Cells (iRow, 1).activate
    iRow = iRow + 1
    Loop

    .Cells (iRow, 1).value=Document.GetElementsByName ("date2") (0).Value
    .Cells (iRow, 2).value=Document.GetElementsByName ("date3") (0).Value
    .Cells (iRow, 3).value=Document.GetElementsByName ("name1") (0).Value
    .Cells (iRow, 4).value=Document.GetElementsByName ("acti") (0).Value
    .Cells (iRow, 5).value=Document.GetElementsByName ("supwho") (0).Value
    .Cells (iRow, 6).value=Document.GetElementsByName ("prowhi") (0).Value
    .Cells (iRow, 7).value=Document.GetElementsByName ("trawha") (0).Value
    .Cells (iRow, 8).value=Document.GetElementsByName ("hanwho") (0).Value
    .Cells (iRow, 9).value=Document.GetElementsByName ("prowha") (0).Value
    .Cells (iRow, 10).value=Document.GetElementsByName ("surwho") (0).Value
    .Cells (iRow, 11).value=Document.GetElementsByName ("letwho") (0).Value
    .Cells (iRow, 12).value=Document.GetElementsByName ("miwha") (0).Value
    .Cells (iRow, 13).value=Document.GetElementsByName ("miwho") (0).Value
    .Cells (iRow, 14).value=Document.GetElementsByName ("time1") (0).Value
    .Cells (iRow, 15).value=Document.GetElementsByName ("desc1") (0).Value



    End With
    ObjWorkbook. Save
    ObjWorkbook. Close
    Set objWorkbook = Nothing
    Set objExcel = Nothing

End Sub
</script>

<style type="text/css">
form    {

    margin: auto;
    position: relative;
    width: 550px;
    height: 450px;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 14px;
    font-style: italic;
    line-height: 24px;
    font-weight: bold;
    color: green;
    text-decoration: none;
    border-radius: 10px;
    padding: 10px;
    border: 1px solid #999;
    border: inset 1px solid #333;
    }
button  {
    width: 100px;
    position: absolute;
    right: 20px;
    bottom: 20px;
    background: #09C;
    color: #fff;
    font-family: Tahoma, Geneva, sans-serif;
    height: 30px;
    border-radius: 15px;
    border: 1p solid #999;
    }

input.button:hover {
    background: #fff;
    color: #09C;
    }
textarea:focus, input:focus {
    border: 1px solid #09C;
    }

</style>


<script type="text/javascript">
function showfield(name){
    hidefield();
    document.getElementById( 'div-' + name).style.display="block";
}


function hidefield() {
document.getElementById('div-1').style.display='none';
document.getElementById('div-2').style.display='none';
document.getElementById('div-3').style.display='none';
document.getElementById('div-4').style.display='none';
document.getElementById('div-5').style.display='none';
document.getElementById('div-6').style.display='none';
document.getElementById('div-7').style.display='none';
document.getElementById('div-8').style.display='none';
}
</script>   
</head>
<body onload="hidefield()">
<form>
<fieldset>
<legend>Diverted Time Sheet</legend>
<center>
Date:<br>
<input id="date" name="date2" maxlength="10" size="10">
<script type="text/javascript">
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1; //January is 0!
    var yyyy = today.getFullYear();
    if(dd<10) {
        dd='0'+dd
    } 
    if(mm<10) {
        mm='0'+mm
    } 
    today = dd+'/'+mm+'/'+yyyy;
    document.getElementById('date').value = today;
    </script>   
<br>
<input type="hidden" id="date1" name="date3">
<script type="text/javascript">
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1;
    var yyyy = today.getFullYear();
    if(dd<10) {
        dd='0'+dd
    } 
    if(mm<10) {
        mm='0'+mm
    } 
    today = dd+'/'+mm+'/'+yyyy;
    document.getElementById('date1').value = today;
    </script>
Name :<br>
<select name="name1" value="">
    <option value="James Dark">James Dark</option>
    <option value="Jane Dean">Jane Dean</option>
    <option value="Leanne Lambert">Leanne Lambert</option>
    <option value="Tracey Stratford">Tracey Stratford</option>
    <option value="Robert Macallan">Robert Macallan</option>
    <option value="Michael Mcdonald">Michael Mcdonald</option>
    <option value="Sarah Murphy">Sarah Murphy</option>
    <option value="Amanda Myatt">Amanda Myatt</option>
    <option value="Joanne Kerley">Joanne Kerley</option>
    <option value="Kay Land">Kay Land</option>
    <option value="John Dinsdale">John Dinsdale</option>
    <option value="Chris Baxter">Chris Baxter</option>
    <option value="Casey Sparkes">Casey Sparkes</option>
    <option value="James Purnell">James Purnell</option>
    <option value="Kate Bingham">Kate Bingham</option>
    <option value="Kevin Dix">Kevin Dix</option>
    <option value="Tyrone Moll">Tyrone Moll</option>
    <option value="Kate Bishop">Kate Bishop</option>
    <option value="Jason Gamble">Jason Gamble</option>
    <option value="Tony Parkinson">Tony Parkinson</option>
    <option value="Tom Seaman">Tom Seaman</option>
    <option value="Carolyn Lester">Carolyn Lester</option>
    <option value="Debbie Gray">Debbie Gray</option>
    <option value="Chris McCormack">Chris McCormack</option>
    <option value="Marion Greenaway">Marion Greenaway</option>
    <option value="Sarah White">Sarah White</option>
    <option value="Angela Manning">Angela Manning</option>
    <option value="Buffy Gammond">Buffy Gammond</option>
    <option value="Andy Holmes">Andy Holmes</option>
    <option value="Nathan Gatehouse">Nathan Gatehouse</option>
    <option value="Dan Bishop">Dan Bishop</option>
    <option value="Heather Townend">Heather Townend</option>
    <option value="Ben Krigers">Ben Krigers</option>
    <option value="Jacob Gibney">Jacob Gibney</option>
    <option value="Robert Mcleish">Robert Mcleish</option>
    <option value="Stuart Vidler">Stuart Vidler</option>
    <option value="Rebekah Coldwell">Rebekah Coldwell</option>
    <option value="Majid Ali">Majid Ali</option>
    <option value="Sharon Borg">Sharon Borg</option>
    <option value="Rich Hall">Rich Hall</option>
    <option value="Paul Dargan">Paul Dargan</option>
    <option value="Mel Davis">Mel Davis</option>
    <option value="Elaine Hawkins">Elaine Hawkins</option>
    <option value="Humma Khan">Humma Khan</option>
    <option value="Chris Jones">Chris Jones</option>
    <option value="Matt Tottle">Matt Tottle</option>
    <option value="Nathan Middleton">Nathan Middleton</option>
    <option value="Helen Wentland">Helen Wentland</option>
    <option value="Adriann Quintas">Adriann Quintas</option>
</select><br>
Activity :<br>
<select name="acti" value="" onchange="showfield(this.options[this.selectedIndex].value)">
    <option value="9">Worked hours</option>
    <option value="10">Overtime</option>
    <option value="11">Sickness</option>
    <option value="12">Unpaid leave</option>
    <option value="13">Compassionate leave</option>
    <option value="14">Holiday inc bank holidays</option>
    <option value="15">Team meetings</option>
    <option value="16">One to ones</option>
    <option value="17">One to one prep</option>
    <option value="18">Huddles</option>
    <option value="1">Supplier meetings</option>
    <option value="2">Product meetings</option>
    <option value="3">Training/coaching</option>
    <option value="4">Handling other peoples cases</option>
    <option value="5">Project work</option>
    <option value="6">Surgery time for GK</option>
    <option value="7">Letter checks and feedback</option>
    <option value="8">MI/Reporting/RCA</option>
</select><br>
<div id="div-1">Supplier meetings with :<br>
<select name="supwho" value="">
    <option value=""></option>
    <option value="Davies">Davies</option>
    <option value="Gelder">Gelder</option>
    <option value="Evander">Evander</option>
    <option value="Brittania Rescue">Brittania Rescue</option>
</select><br></div>
<div id="div-2">Which product meeting :<br>
<select name="prowhi" value="">
    <option value=""></option>
    <option value="Home">Home</option>
    <option value="Motor">Motor</option>
    <option value="Legal">Legal</option>
    <option value="Travel">Travel</option>
</select><br></div>
<div id="div-3">What training/coaching :<br>
<select name="trawha" value="">
    <option value=""></option>
    <option value="Leon">Leon</option>
    <option value="Releases">Releases</option>
    <option value="Complaint">Complaint</option>
    <option value="Team leader">Team leader</option>
    <option value="Updates">Updates</option>
    <option value="Other">Other</option>
</select><br></div>
<div id="div-4">Whos case handling :<br>
<select name="hanwho" value="">
    <option value=""></option>
    <option value="James Dark">James Dark</option>
    <option value="Jane Dean">Jane Dean</option>
    <option value="Leanne Lambert">Leanne Lambert</option>
    <option value="Tracey Stratford">Tracey Stratford</option>
    <option value="Robert Macallan">Robert Macallan</option>
    <option value="Michael Mcdonald">Michael Mcdonald</option>
    <option value="Sarah Murphy">Sarah Murphy</option>
    <option value="Amanda Myatt">Amanda Myatt</option>
    <option value="Joanne Kerley">Joanne Kerley</option>
    <option value="Kay Land">Kay Land</option>
    <option value="John Dinsdale">John Dinsdale</option>
    <option value="Chris Baxter">Chris Baxter</option>
    <option value="Casey Sparkes">Casey Sparkes</option>
    <option value="James Purnell">James Purnell</option>
    <option value="Kate Bingham">Kate Bingham</option>
    <option value="Kevin Dix">Kevin Dix</option>
    <option value="Tyrone Moll">Tyrone Moll</option>
    <option value="Kate Bishop">Kate Bishop</option>
    <option value="Jason Gamble">Jason Gamble</option>
    <option value="Tony Parkinson">Tony Parkinson</option>
    <option value="Tom Seaman">Tom Seaman</option>
    <option value="Carolyn Lester">Carolyn Lester</option>
    <option value="Debbie Gray">Debbie Gray</option>
    <option value="Chris McCormack">Chris McCormack</option>
    <option value="Marion Greenaway">Marion Greenaway</option>
    <option value="Sarah White">Sarah White</option>
    <option value="Angela Manning">Angela Manning</option>
    <option value="Buffy Gammond">Buffy Gammond</option>
    <option value="Andy Holmes">Andy Holmes</option>
    <option value="Nathan Gatehouse">Nathan Gatehouse</option>
    <option value="Dan Bishop">Dan Bishop</option>
    <option value="Heather Townend">Heather Townend</option>
    <option value="Ben Krigers">Ben Krigers</option>
    <option value="Jacob Gibney">Jacob Gibney</option>
    <option value="Robert Mcleish">Robert Mcleish</option>
    <option value="Stuart Vidler">Stuart Vidler</option>
    <option value="Rebekah Coldwell">Rebekah Coldwell</option>
    <option value="Majid Ali">Majid Ali</option>
    <option value="Sharon Borg">Sharon Borg</option>
    <option value="Rich Hall">Rich Hall</option>
    <option value="Paul Dargan">Paul Dargan</option>
    <option value="Mel Davis">Mel Davis</option>
    <option value="Elaine Hawkins">Elaine Hawkins</option>
    <option value="Humma Khan">Humma Khan</option>
    <option value="Chris Jones">Chris Jones</option>
    <option value="Matt Tottle">Matt Tottle</option>
    <option value="Nathan Middleton">Nathan Middleton</option>
    <option value="Helen Wentland">Helen Wentland</option>
    <option value="Adriann Quintas">Adriann Quintas</option>
    <option value="Business area">Business area</option>
</select><br></div>
<div id="div-5">What project work :<br>
<select name="prowha" value="">
    <option value=""></option>
    <option value="FCA changes">FCA changes</option>
    <option value="Audit">Audit</option>
    <option value="RCA">RCA</option>
</select><br></div>
<div id="div-6">Surgery time with who :<br>
<select name="surwho" value="">
    <option value=""></option>
    <option value="James Dark">James Dark</option>
    <option value="Jane Dean">Jane Dean</option>
    <option value="Leanne Lambert">Leanne Lambert</option>
    <option value="Tracey Stratford">Tracey Stratford</option>
    <option value="Robert Macallan">Robert Macallan</option>
    <option value="Michael Mcdonald">Michael Mcdonald</option>
    <option value="Sarah Murphy">Sarah Murphy</option>
    <option value="Amanda Myatt">Amanda Myatt</option>
    <option value="Joanne Kerley">Joanne Kerley</option>
    <option value="Kay Land">Kay Land</option>
    <option value="John Dinsdale">John Dinsdale</option>
    <option value="Chris Baxter">Chris Baxter</option>
    <option value="Casey Sparkes">Casey Sparkes</option>
    <option value="James Purnell">James Purnell</option>
    <option value="Kate Bingham">Kate Bingham</option>
    <option value="Kevin Dix">Kevin Dix</option>
    <option value="Tyrone Moll">Tyrone Moll</option>
    <option value="Kate Bishop">Kate Bishop</option>
    <option value="Jason Gamble">Jason Gamble</option>
    <option value="Tony Parkinson">Tony Parkinson</option>
    <option value="Tom Seaman">Tom Seaman</option>
    <option value="Carolyn Lester">Carolyn Lester</option>
    <option value="Debbie Gray">Debbie Gray</option>
    <option value="Chris McCormack">Chris McCormack</option>
    <option value="Marion Greenaway">Marion Greenaway</option>
    <option value="Sarah White">Sarah White</option>
    <option value="Angela Manning">Angela Manning</option>
    <option value="Buffy Gammond">Buffy Gammond</option>
    <option value="Andy Holmes">Andy Holmes</option>
    <option value="Nathan Gatehouse">Nathan Gatehouse</option>
    <option value="Dan Bishop">Dan Bishop</option>
    <option value="Heather Townend">Heather Townend</option>
    <option value="Ben Krigers">Ben Krigers</option>
    <option value="Jacob Gibney">Jacob Gibney</option>
    <option value="Robert Mcleish">Robert Mcleish</option>
    <option value="Stuart Vidler">Stuart Vidler</option>
    <option value="Rebekah Coldwell">Rebekah Coldwell</option>
    <option value="Majid Ali">Majid Ali</option>
    <option value="Sharon Borg">Sharon Borg</option>
    <option value="Rich Hall">Rich Hall</option>
    <option value="Paul Dargan">Paul Dargan</option>
    <option value="Mel Davis">Mel Davis</option>
    <option value="Elaine Hawkins">Elaine Hawkins</option>
    <option value="Humma Khan">Humma Khan</option>
    <option value="Chris Jones">Chris Jones</option>
    <option value="Matt Tottle">Matt Tottle</option>
    <option value="Nathan Middleton">Nathan Middleton</option>
    <option value="Helen Wentland">Helen Wentland</option>
    <option value="Adriann Quintas">Adriann Quintas</option>
    <option value="Business area">Business area</option>
</select><br></div>
<div id="div-7">Letter check for who :<br>
<select name="letwho" value="">
    <option value=""></option>
    <option value="James Dark">James Dark</option>
    <option value="Jane Dean">Jane Dean</option>
    <option value="Leanne Lambert">Leanne Lambert</option>
    <option value="Tracey Stratford">Tracey Stratford</option>
    <option value="Robert Macallan">Robert Macallan</option>
    <option value="Michael Mcdonald">Michael Mcdonald</option>
    <option value="Sarah Murphy">Sarah Murphy</option>
    <option value="Amanda Myatt">Amanda Myatt</option>
    <option value="Joanne Kerley">Joanne Kerley</option>
    <option value="Kay Land">Kay Land</option>
    <option value="John Dinsdale">John Dinsdale</option>
    <option value="Chris Baxter">Chris Baxter</option>
    <option value="Casey Sparkes">Casey Sparkes</option>
    <option value="James Purnell">James Purnell</option>
    <option value="Kate Bingham">Kate Bingham</option>
    <option value="Kevin Dix">Kevin Dix</option>
    <option value="Tyrone Moll">Tyrone Moll</option>
    <option value="Kate Bishop">Kate Bishop</option>
    <option value="Jason Gamble">Jason Gamble</option>
    <option value="Tony Parkinson">Tony Parkinson</option>
    <option value="Tom Seaman">Tom Seaman</option>
    <option value="Carolyn Lester">Carolyn Lester</option>
    <option value="Debbie Gray">Debbie Gray</option>
    <option value="Chris McCormack">Chris McCormack</option>
    <option value="Marion Greenaway">Marion Greenaway</option>
    <option value="Sarah White">Sarah White</option>
    <option value="Angela Manning">Angela Manning</option>
    <option value="Buffy Gammond">Buffy Gammond</option>
    <option value="Andy Holmes">Andy Holmes</option>
    <option value="Nathan Gatehouse">Nathan Gatehouse</option>
    <option value="Dan Bishop">Dan Bishop</option>
    <option value="Heather Townend">Heather Townend</option>
    <option value="Ben Krigers">Ben Krigers</option>
    <option value="Jacob Gibney">Jacob Gibney</option>
    <option value="Robert Mcleish">Robert Mcleish</option>
    <option value="Stuart Vidler">Stuart Vidler</option>
    <option value="Rebekah Coldwell">Rebekah Coldwell</option>
    <option value="Majid Ali">Majid Ali</option>
    <option value="Sharon Borg">Sharon Borg</option>
    <option value="Rich Hall">Rich Hall</option>
    <option value="Paul Dargan">Paul Dargan</option>
    <option value="Mel Davis">Mel Davis</option>
    <option value="Elaine Hawkins">Elaine Hawkins</option>
    <option value="Humma Khan">Humma Khan</option>
    <option value="Chris Jones">Chris Jones</option>
    <option value="Matt Tottle">Matt Tottle</option>
    <option value="Nathan Middleton">Nathan Middleton</option>
    <option value="Helen Wentland">Helen Wentland</option>
    <option value="Adriann Quintas">Adriann Quintas</option>
    <option value="Business area">Business area</option>
</select><br></div>
<div id="div-8">What MI/Reporting/RCA :<br>
<select name="miwha" value="">
    <option value=""></option>
    <option value="Nationwide">Nationwide</option>
    <option value="Daily Review">Daily Review</option>
    <option value="Adhoc">Adhoc</option>
</select><br>
Who requested MI/Reporting/RCA :<br>
<select name="miwho" value="">
    <option value=""></option>
    <option value="Chris Joy">Chris Joy</option>
    <option value="Nadine Ralph">Nadine Ralph</option>
    <option value="Darrel Minvalla">Darrel Minvalla</option>
    <option value="Amanda May">Amanda May</option>
    <option value="Treca Legg">Treca Legg</option>
    <option value="Business Area">Business Area</option>
</select><br></div>
<div id="div-9"></div><div id="div-10"></div><div id="div-11"></div><div id="div-12"></div><div id="div-13"></div><div id="div-14"></div><div id="div-15"></div><div id="div-16"></div><div id="div-17"></div><div id="div-18"></div>
Time in minutes :<br>
<input type="text" name="time1" Value="">
<br>
Description :<br>
<input type="text" name="desc1" Value=""><br>
<br>
<input type="button" onclick="Divert()" value="Submit"><br>
</center>
</fieldset>
</form>
</body>
</html>

我已经做了一段时间了,我很难过,任何帮助都会非常感激。

它将同事在白天所做的操作写入电子表格,以便可以在内部网络上进行审核。

由于

0 个答案:

没有答案