Automate Excel from ASP

O

Oscar Picos

Hello:

I would like to know how can I automate Excel Application
(no ADO) from ASP pages.

I instanciated OWC10.Spreadsheet object and I can see in
the browser, but I need to open a workbook and run a VBA
macro into it (this generate and public an HTML page)
then, this HTML page will be seen at the browser.

Any comment It will be appreciated.

Thank you very much.

Oscar Picos
Office autom
 
M

michael weiss

This is some code that opens a workbook and reads values
into a spreadsheet from an html table...maybe by looking
through it you can see how to modify it to get you started
in the direction you need to go in...I remember something
about running a macro from a workbook created
programmatically but do not recall how to do that exactly
now.
Anyway, maybe this will help get you closer...
Michael

<script language="VBScript">
Sub SendToExcel(sheetname)
Dim objExcel
Dim workbook
Dim sheet
Dim table
Dim r
Dim c
Dim tmp
Dim activecell
Dim intOrigNumSheets
Dim intNumSheets

intNumSheets = 1

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
intOrigNumSheets = objExcel.SheetsInNewWorkbook
If intOrigNumSheets <> intNumSheets Then
objExcel.SheetsInNewWorkbook = intNumSheets
End If

Set workbook = objExcel.Workbooks.Add()
Set sheet = workbook.activesheet
With sheet
.name = CStr(sheetname)
.Range("A1").Select
End With
Set activecell = objExcel.Selection
If Not objExcel IS NOTHING Then
'MsgBox "Excel Object Instantiated"
On Error Resume Next
Set table = document.getelementbyid("datatable")
For r =0 to document.all.datatable.rows.length - 1
For c = 0 to document.all.datatable.rows
(r).cells.length - 1
tmp = document.all.datatable.rows(r).cells
(c).innerText
activecell.offset(r-1,c).value =
tmp
Next
Next
objExcel.SheetsInNewWorkbook = intOrigNumSheets
End If

Set activecell = Nothing
Set table = Nothing
Set sheet = Nothing
Set workbook = Nothing
Set objExcel = Nothing
End Sub 'SendToExcel
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top