Excel._Worksheet.SaveAs

G

Guest

The applicacion sends me the next message "Method not found:
Excel._Worksheet.SaveAs (..."

I thinks that its about permissions but I do not know how to fix it.

I have the same source in two different servers, It work in one of these but
it doesn's work in the second one.

oExcel = New Excel.Application
oExcel.Visible = False : oExcel.DisplayAlerts = False
'Start a new workbook
oBooks = oExcel.Workbooks
oBooks.Open(sTemplate)
......
oSheet.SaveAs(sFile) ' Error in this line

The source is VB .net
 
G

Guest

What version of Excel are you using in each place? Are the same? I *guess*
Excel 2007 has WorkSheet.SaveAs() while Excel 2003 doesn't ???
 
G

Guest

I am using Excel 2003 in both servers.

There is my source:

'' Creamos un objeto Excel
Dim oExcel As Excel.Application
Dim oBooks As Excel.Workbooks, oBook As Excel.Workbook
Dim oSheets As Excel.Sheets, oSheet As Excel.Worksheet
Dim oCells As Excel.Range
Dim sFile As String, sTemplate As String

Dim ds As DataSet
Dim iCodigoError As Integer
Dim i, j, iCuantas, iAuxiliar, iPosicion As Integer
Dim sRango1, sRango2, sLetra As String
'Dim p As System.Diagnostics.Process = New System.Diagnostics.Process
Dim vCultura As System.Globalization.CultureInfo =
System.Threading.Thread.CurrentThread.CurrentCulture
Dim dsBitacora As DataSet
Try
'idInstitucion = 9
'idDisposicion = "BANORTE0002"
'idCartera = "E"

'Se establece en inglés la información regional para el
'subproceso actual antes de crear una instancia de Excel
System.Threading.Thread.CurrentThread.CurrentCulture =
System.Globalization.CultureInfo.CreateSpecificCulture("en-US")

i = 1
'asigna rutas para la busqueda del xls base
sFile = Server.MapPath("")
iPosicion = sFile.LastIndexOf(objSeguridad.NombreSitio & "\")
sTemplate = sFile.Substring(0, iPosicion) &
objSeguridad.NombreSitio & "\LibrosExcel\base\MyTemplate.xls"
sFile = sFile.Substring(0, iPosicion) & objSeguridad.NombreSitio
& "\LibrosExcel\MyExcel.xls"

sSql = "Select cl.Descripcion, cc.idCampo from
oCesionLayoutInstitucion cl, cCamposLayoutCesion cc " & _
"where cl.idInstitucion=" & idInstitucion & _
"and cl.IndicadorTipoCartera='" & idCartera & "' and
cc.idCampo=cl.idCampo " & _
"Order by Orden"
objLector = objAccesaBD.fsqldrLeeBD(sSql)
If objLector.HasRows = True Then
ds = objCesion.fdsCesionCreaLayout(idInstitucion,
idDisposicion, idCartera)
If Not ds Is Nothing Then
If ds.Tables(0).Rows.Count <> 0 Then
oExcel = New Excel.Application
'oExcel.Visible = True
oExcel.Visible = False : oExcel.DisplayAlerts = False
'Start a new workbook
oBooks = oExcel.Workbooks
oBooks.Open(sTemplate)
oBook = oBooks.Item(1)
oSheets = oBook.Worksheets
oSheet = CType(oSheets.Item(1), Excel.Worksheet)
'oBook = oExcel.Workbooks.Add
'oSheet = oBook.Worksheets(1)
'oSheet.Visible =
Excel.XlSheetVisibility.xlSheetVisible
'oSheet.Activate()
oSheet.Name = idDisposicion
oCells = oSheet.Cells

'Campos para cabeceras
iCuantas = ds.Tables(0).Rows.Count - 1
If iCuantas = 0 Then iCuantas = 1

While objLector.Read
oSheet.Cells(1, i) = objLector.GetValue(0)
iAuxiliar = objLector.GetValue(1)
If fFormatoNumero(iAuxiliar) Then
sLetra = fEquivalenteLetra(i)
sRango1 = sLetra & 2

sRango2 = sLetra & iCuantas

oCells = oSheet.Range(sRango1, sRango2)
oCells.EntireColumn.NumberFormat =
"###,###,##0.00"
End If
i = i + 1
End While
Else
sError = "No existen datos."
Err.Raise(1)
End If
For i = 0 To ds.Tables(0).Rows.Count - 1
For j = 0 To ds.Tables(0).Columns.Count - 1
If i = 0 Then
i = 1
oSheet.Cells(i + 1, j + 1) =
ds.Tables(0).Rows(i - 1).ItemArray(j)
i = 0
Else
oSheet.Cells(i + 2, j + 1) =
ds.Tables(0).Rows(i).ItemArray(j)
End If
Next
Next
Else
sError = "Error en la generación del layout."
Err.Raise(1)
End If
Else
sError = "No existe configuración para el layout."
Err.Raise(1)
End If
' Bitacora
dsBitacora =
objAdministracion.fdsBitacora(Session("ClaveUsuario"), "Cesión -- Exportar",
"E", " Institución: " & CStr(idInstitucion) & " Disposición: " &
idDisposicion & " Cartera : " & CStr(idCartera), 0)

oSheet.SaveAs(sFile) 'Salva el archivo nuevo en LibrosExcel
 
G

Guest

I debug and comment the SaveAS line, I run again my application and it sends
me an error in the line with a Open() method.

That's why i am thinking that it a permissions issue.
 

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