Visual Basic - no se si se puede

Life is soft - evento anual de software empresarial
 
Vista:

no se si se puede

Publicado por GUSTAVO (181 intervenciones) el 19/10/2004 16:45:42
Hola
quisiera saber si se puede q en una hoja de exel q ya cree cambiarle el formato a la celda es decir el tamaño de letra, negrita cursiva, centrado, etc

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: no se si se puede

Publicado por miguel (1042 intervenciones) el 19/10/2004 20:22:35
Si se puede...ejemplo abrir un archivo excel que ya existe:
Dim xlApp As Excel.Application
Dim mySheet As Excel.Worksheet
Private Sub cmdExcel_Click()
On Error GoTo Errores
Dim vlRuta As String
Set xlApp = CreateObject("Excel.Application")
vlRuta = App.Path & "\Libro1.xls"
xlApp.Workbooks.Open vlRuta
Set mySheet = xlApp.Worksheets(1)
With mySheet
.Cells(1, 1) = "Prueba"
.Cells(1, 2) = "Prueba2"
.Cells(2, 1) = "Prueba3"
.Cells(2, 2) = "Prueba4"
.Range("A1:B10").Font.Color = vbRed 'Color de Letra
.Range("A1:B10").HorizontalAlignment = xlHAlignCenter 'Centrado Hor.
.Range("A1:B10").VerticalAlignment = xlHAlignCenter 'Centrado Vert.
.Range("A1:B10").Font.Name = "Tahoma" 'Nombre Letra
.Range("A1:B10").Font.Size = 11 'Tamaño
.Range("A1:B10").Font.Bold = True 'Negrita
.Range("A1:B10").Font.Italic = True 'Cursiva
.Range("A1:B10").Interior.Color = vbYellow 'Color de Relleno
End With

MsgBox "Proceso Terminado", vbInformation
xlApp.DisplayAlerts = False
mySheet.SaveAs App.Path & "\Libro1.xls"
xlApp.Quit
Set xlApp = Nothing
Errores:
If Err.Number <> 0 Then
xlApp.Quit
Set xlApp = Nothing
MsgBox Err.Description, vbCritical, CStr(Err.Number)
Err.Clear
End If
End Sub
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

RE: no se si se puede

Publicado por Zorro262004 (9 intervenciones) el 20/10/2004 00:34:17
'Haber amigo prueba esto, con esta pista me imagino que te las ingeniaras para completar los demas. no esta muy dificil.

Private Sub ExcelEsport(rs As ADODB.Recordset)
Dim D As String

rs.MoveFirst
'On Error GoTo Etiqueta
Dim ApExcel As Variant
Set ApExcel = CreateObject("Excel.application")
With ApExcel
.Visible = True
.Workbooks.Add
.Cells(1, 1).Formula = UCase$("Cia. Industrial Continental S.R.L")
.Range("A1:D1").Font.Bold = True
.Cells(2, 1).Formula = UCase$("Inventario de Cajamarquilla al 29/06/2004")
.Cells(3, 1).Formula = UCase$(Titulo)
.Cells(4, 1).Formula = "AREA: " & DtAlmacen.Text
.Range("A2:D4").Font.Italic = True
Dim X As Integer
Dim Y As Integer
Y = 6
For X = 1 To rs.Fields.Count
.Cells(Y, X).Formula = rs.Fields(X - 1).Name
DoEvents
Next

Do Until rs.EOF
Y = Y + 1
For X = 1 To rs.Fields.Count
D = Chr(X + 64) & Y
.Range(D).Formula = CStr(rs.Fields(X - 1))
DoEvents
Next
rs.MoveNext
DoEvents
Loop
.Range("A6:" & D).Borders.Color = RGB(0, 0, 0)

End With
Set ApExcel = Nothing
' Exit Sub
'Etiqueta:
'
' MsgBox Err.Description, vbInformation, App.Title
End Sub
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