No funciona el Workbooks.open en asp
Publicado por David (3 intervenciones) el 18/10/2005 09:06:03
Hola.
Alguien podría decirme porque no funciona el workbooks.open, me cuelga la página cuando a leer el fichero que he subido al servidor.
Lo he probado todo y no hay manera, con la ruta directa (C:\inetpub\wwwroot\...\nombrefichero.xls) y usando el Server.MapPath...
On error resume next
dim mySmartUpload
Dim intCount
const NFilas = 21
const NCols = 10
dim tabla(21, 17)
const MaxSheet = 3
Server.ScriptTimeOut = 3600
' Object creation
' ***************
'Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
'mySmartUpload.Upload
'Ruta donde se va a guardar el fichero excel.
'intCount = mySmartUpload.Save(Server.MapPath("./Temp/"))
For each file In mySmartUpload.files
if len(file.Filename) > 0 then
fichero = file.filename
end if
next
'***************************************
' Veamos si podemos abrir y cerrar un objeto Excel
'***************************************
Dim objExcel
Dim objWorkBook
Set objExcel = CreateObject("EXCEL.APPLICATION")
'LO SIGUIENTE HACE QUE LA PAGINA SE QUEDE ESTANCADA INDEFINIDAMENTE
Set objWorkBook = objExcel.Workbooks.Open(Server.MapPath("./Temp") + "\08_05_definitivosVII.xls")
Set objWorkBook = objExcel.Workbooks.Open("http://176.16.2.146/Temp/08_05_definitivosVII.xls")
objExcel.visible = false
'Intentamos cerrarlo.
objExcel.WorkBooks.close()
objExcel.Application.quit()
set objExcel = Nothing
Response.Write "Excel cerrado" & vbcrlf
'***************************************
' Borrado del fichero subido en el servidor.
'***************************************
'dim fs,f
'set fs=Server.CreateObject("Scripting.FileSystemObject")
'set f=fs.GetFile(Server.MapPath("./Temp/") + "\" + fichero)
f.Delete
set f=nothing
set fs=nothing
if (err.number <> 0) then
Response.write "<br>" & "El fichero " & fichero & " NO se ha insertado correctamente."
else
Response.write "<br>" & "El fichero " & fichero & " se ha insertado correctamente."
end if
Alguna sugerencia.
Alguien podría decirme porque no funciona el workbooks.open, me cuelga la página cuando a leer el fichero que he subido al servidor.
Lo he probado todo y no hay manera, con la ruta directa (C:\inetpub\wwwroot\...\nombrefichero.xls) y usando el Server.MapPath...
On error resume next
dim mySmartUpload
Dim intCount
const NFilas = 21
const NCols = 10
dim tabla(21, 17)
const MaxSheet = 3
Server.ScriptTimeOut = 3600
' Object creation
' ***************
'Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
'mySmartUpload.Upload
'Ruta donde se va a guardar el fichero excel.
'intCount = mySmartUpload.Save(Server.MapPath("./Temp/"))
For each file In mySmartUpload.files
if len(file.Filename) > 0 then
fichero = file.filename
end if
next
'***************************************
' Veamos si podemos abrir y cerrar un objeto Excel
'***************************************
Dim objExcel
Dim objWorkBook
Set objExcel = CreateObject("EXCEL.APPLICATION")
'LO SIGUIENTE HACE QUE LA PAGINA SE QUEDE ESTANCADA INDEFINIDAMENTE
Set objWorkBook = objExcel.Workbooks.Open(Server.MapPath("./Temp") + "\08_05_definitivosVII.xls")
Set objWorkBook = objExcel.Workbooks.Open("http://176.16.2.146/Temp/08_05_definitivosVII.xls")
objExcel.visible = false
'Intentamos cerrarlo.
objExcel.WorkBooks.close()
objExcel.Application.quit()
set objExcel = Nothing
Response.Write "Excel cerrado" & vbcrlf
'***************************************
' Borrado del fichero subido en el servidor.
'***************************************
'dim fs,f
'set fs=Server.CreateObject("Scripting.FileSystemObject")
'set f=fs.GetFile(Server.MapPath("./Temp/") + "\" + fichero)
f.Delete
set f=nothing
set fs=nothing
if (err.number <> 0) then
Response.write "<br>" & "El fichero " & fichero & " NO se ha insertado correctamente."
else
Response.write "<br>" & "El fichero " & fichero & " se ha insertado correctamente."
end if
Alguna sugerencia.
Valora esta pregunta


0