Visual Basic - visual y excel ayuda expertos

Life is soft - evento anual de software empresarial
 
Vista:

visual y excel ayuda expertos

Publicado por Marco (24 intervenciones) el 01/02/2005 14:44:25
Private Sub cmdtoexcell_Click()
Dim wkbNew As Excel.Workbook
Dim wkbSheet As Excel.Worksheet
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
xlApp.Visible = True
Dim Rng As Excel.Range
If Dir("C:\movimiento de entrada.xls") <> "" Then 'Si Existe el Archivo
Kill "C:\movimiento de entrada.xls" 'Lo Eliminamos
End If
'Set xlWB = xlApp.Workbooks.Add
Set wkbNew = Workbooks.Add
wkbNew.SaveAs "C:\movimiento de entrada.xls"
Set wkbSheet = wkbNew.Worksheets(1)
wkbSheet.Cells(1, 1) = "CODIGO"
wkbSheet.Cells(1, 2) = "NOMBRE PRODUCTO"
wkbSheet.Cells(1, 3) = "CANTIDAD"
wkbSheet.Cells(1, 4) = "FECHA DE INGRESO"
wkbSheet.Cells(1, 5) = "PROVEEDOR"
' Hace una Seleccion de celdas y pone bordes de Color
wkbSheet.Range("A1:E1").Borders.Color = RGB(255, 0, 0)
Set Rng = wkbSheet.Range("A2:" + Chr(DataGrid1.Columns.Count + 64) + CStr(Adodc1.Recordset.RecordCount))
DataGrid1.Row = 0 'se coloca el cursor en la primera fila
DataGrid1.Refresh
For I = 0 To Adodc1.Recordset.RecordCount - 1
For j = 0 To DataGrid1.Columns.Count - 1
DataGrid1.Col = j
Rng.Range(Chr(j + 1 + 64) + CStr(I + 1)) = DataGrid1.Text ' AQUI SE CAE Y DICE QUE HAY ERROR DE ACCESO A RUTA O ARCHIVO
Next j
Adodc1.Recordset.MoveNext
Next I
wkbNew.Close True
'Si queremos Abrir el Archivo
Dim MyValue
MyValue = Shell("rundll32.exe url.dll,FileProtocolHandler " & "C:\movimiento de entrada.xls")
Set wkbNew = Nothing
Set wkbSheet = Nothing
Set Rng = Nothing
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:visual y excel ayuda expertos

Publicado por Marco (24 intervenciones) el 01/02/2005 14:46:34
Cuando lo bajo una ves lo baja sin ningun problema pero si lo quiero bajar por segunda sin haber cerrado el programa se cae en la linea
Rng.Range(Chr(j + 1 + 64) + CStr(I + 1)) = DataGrid1.Text ' AQUI SE CAE Y DICE QUE HAY ERROR DE ACCESO A RUTA O ARCHIVO
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar