Visual Basic - crear libro excel

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

crear libro excel

Publicado por raymond (107 intervenciones) el 13/07/2006 23:54:15
Buenas

mi opregunta es como puedo crear el libro excel desde visual?, porque tengo que tener ya creado el libro excel en la carpeta para poderlo manejar pero si yo quiero crear uno desde visual no puedo...

me podria alguien por favor ayudar?

Gracias =)
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:crear libro excel

Publicado por miguel (1042 intervenciones) el 14/07/2006 23:35:34
Debes de dar alta la referencia de excel (Menu Proyectos-->Referencias)dependiendo que version de office tengas debe haber una con el nombre:
Microsoft Excel 11.0 Object Library
Nota. Lo que varia es la versión.
Private Sub Command2_Click()
Dim ApExcel As Excel.Application
Set ApExcel = CreateObject("Excel.application")

ApExcel.Workbooks.Add
With ApExcel
.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
'Poner Border
' 'XlLineStyle: xlContinuous, xlDash, xlDashDot, xlDashDotDot, xlDot, xlDouble, xlSlantDashDot o xlLineStyleNone
.Range("A1:B10").Borders.LineStyle = xlContinuous
End With
With ApExcel.Range("A1:B10")
.HorizontalAlignment = xlHAlignLeft
.VerticalAlignment = xlHAlignCenter
.WrapText = True 'Ajustar Celda al Tamañao del Texto
End With
'
ApExcel.AlertBeforeOverwriting = False
ApExcel.ActiveWorkbook.SaveAs "C:\Prueba.xls"
ApExcel.Visible = True
'
Set ApExcel = Nothing
'
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