Hi, I have a VBScript function to export to excel - it finds an item on the page and then grabs the outerHTML and uses the COM components of Excel to write it out.
However, it writes out nothing and a msgbox check to see what the HTML is is empty.
The page is a content page in a master page (i.e. the grid and the export function and button are all in a content page, not a single HTML page). would this affect it? Here is what I believe is the offending line:
The whole function, pretty common, it is someone else's, is here:
Thanks!
James
However, it writes out nothing and a msgbox check to see what the HTML is is empty.
The page is a content page in a master page (i.e. the grid and the export function and button are all in a content page, not a single HTML page). would this affect it? Here is what I believe is the offending line:
Code:
<script type="text/vbscript" language="vbscript">
sHTML = document.all("grid").outerHTML
msgbox(sHTML)
The whole function, pretty common, it is someone else's, is here:
Code:
<script type="text/vbscript" language="vbscript">
Function Export()
ON ERROR RESUME NEXT
DIM sHTML, oExcel, fso, filePath
sHTML = document.all("grid").outerHTML
msgbox(sHTML)
SET fso = CreateObject("Scripting.FileSystemObject")
filePath = fso.GetSpecialFolder(2) & "\MyExportedExcel.xls"
fso.CreateTextFile(filePath).Write(sHTML)
DIM i
SET i = 0
DO WHILE err.number > 0
err.Clear()
filePath = fso.GetSpecialFolder(2) & "\MyExportedExcel" & i & ".xls"
fso.CreateTextFile(filePath).Write(sHTML)
i = i + 1
LOOP
SET oExcel = CreateObject("Excel.Application")
IF err.number>0 OR oExcel =NULL THEN
msgbox("You need to have Excel Installed and Active-X Components Enabled on your System.")
EXIT FUNCTION
END IF
oExcel.Workbooks.open(filePath)
oExcel.Workbooks(1).WorkSheets(1).Name = "My Excel Data"
oExcel.Visible = true
Set fso = Nothing
End Function
</script>
<asp:Button UseSubmitBehavior="false" Text="click" runat="server" OnClientClick="Export()" />
Thanks!
James