从html界面写入值到excel文档



我有一个应用程序,它应该从html界面中获取几个字符串,并将值写入excel文档。

目前所发生的一切是前两个单元格包含不断更新的数字,第三个单元格包含"[object]"

sub Export  
    Dim URL         ' URL being saved to Excel
    Dim FileName        ' Name for file being saved
    Dim FullPath        ' Path of file
    Dim oExcel          ' Excel
    Dim oBook           ' Workbooks
    Dim oSheet          ' Worksheets
    Dim iv              ' Interval value  
    Dim Target          ' Target  FilePath
        
    set FSO = CreateObject("Scripting.FileSystemObject")
    FullPath = FSO.GetAbsolutePathName(folderName)                  
    Target = FullPath & "list.xls"
    Set oExcel = CreateObject("Excel.Application")  
    oExcel.Application.Visible = True
    Set oBook = oExcel.Workbooks.Open(Cstr(target))
        
    iv = 0
        
    While iv <= IC  
         URL =Cstr (URL & iv) 
         FileName = Cstr(FileName & iv)
            
        'Writes values to excel
        oExcel.Cells(1,3).value=IC   <-- ( this is the problem )
        oExcel.Cells(1,1).value=URL
        oExcel.Cells(1,2).value=FileName
        iv = iv + 1
    Wend        
        
    oBook.Save
    oExcel.Quit
        
End sub 
<Body>
    <input type="Button" value="Add to Queue" name="Export_Run" onclick="Export">
    <input type="Button" value="Extract"    name="Extractor_Run" onclick="Extract">         
    
    URL         <input type="Text" value="" name=URL> <br>
    File Name   <input type="Text" value="" name=FileName> <br>
    No. Pages   <input type="Text" value="" name=IC> <br>       
</Body>

经过7年的个人学习编程,现在很明显,问题是我正在编写html元素到文档,而不是html元素的值。

IC_HTMLInputElement对象。要从输入字段中获取文本,您应该使用IC_.Value,如果要将其与另一个整数进行比较,则需要将其转换为整数。此外,您应该只分配一次值,并在脚本的其余部分使用转换后的值。

...
'sets Interval cap
ic = CLng(IC_.Value)
set FSO = CreateObject("Scripting.FileSystemObject")
FullPath = FSO.GetAbsolutePathName(folderName)
Target = FullPath & "list.xls"
Set oExcel = CreateObject("Excel.Application")
oExcel.Application.Visible = True
Set oBook = oExcel.Workbooks.Open(Cstr(target))
iv = 0
ic = IC_
While iv <= ic 
    URL = Cstr (URL_1 & iv) 
    FileName = Cstr(FileName_1 & iv)
    oExcel.Cells(1,3).value = ic
    oExcel.Cells(1,1).value = URL
    oExcel.Cells(1,2).value = FileName
    iv = iv + 1
Wend
...

相关内容

  • 没有找到相关文章

最新更新