Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/08/2004, 07:33
Avatar de lucasiramos
lucasiramos
 
Fecha de Ingreso: agosto-2004
Ubicación: Santa Rosa, La Pampa, Argentina
Mensajes: 1.484
Antigüedad: 19 años, 8 meses
Puntos: 13
Respuesta

Hola. Aca te van algunos tips:

Antes que nada tenes que activar la referencia a Excel (Microsoft Excel 10.0 Object Library). Luego defini una variable de tipo Excel.Application. Aca te paso el codigo con su comentario de lo que hace cada linea

Set Planilla = New Excel.Application '
Planilla.Visible = True ' Abre el libro
Planilla.Workbooks.Add '

Planilla.Worksheets(1).Range("A3").Value = txt.Text ' Con este asocias la celda que quieras al contenido del objeto/variable (La grilla en tu caso).

Planilla.Worksheets(1).Range("A2:C8").Select 'Selecciona el rango
Planilla.Worksheets(1).Range("A2:A8").Merge 'Une las celdas
Planilla.Worksheets(1).Range("A2:A8").AutoFormat (1) 'Aplica el autoformato definido en el parametro

Planilla.Selection.Font.Bold = True
Planilla.Selection.Font.Name = "Tahoma"
Planilla.Selection.Font.Size = 12 'Formato de texto
'Planilla.Selection.Font.Italic = True
'Planilla.Selection.Font.Underline = True

Planilla.Selection.Font.ColorIndex = 35 'Color de fuente
Planilla.Selection.Interior.ColorIndex = 31 'Color de interior de la celda
Planilla.Selection.Borders.ColorIndex = 1 'Color de la celda
Planilla.Selection.Borders.Weight = 4 'Ancho de la celda (de 1 a 4 solamente)
Planilla.Selection.Borders.LineStyle = xlDouble 'Estilo de borde


'Bordes personalizados
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

Planilla.Selection.Font.Superscript = True 'Texto en superindice
Planilla.Selection.Font.Subscript = True 'Texto en subindice

'Alineado de celdas
With Selection
.HorizontalAlignment = xlRight 'xlCenter | xlleft
.VerticalAlignment = xlBottom
End With

'Tamaño de celdas
Planilla.Selection.ColumnWidth = 15
Planilla.Selection.RowHeight = 15

'Insertar imagenes
ActiveSheet.Pictures.Insert("C:\Mis documentos\Lucas\Imagenes\Castillo.jpg").Select 'Inserta imagen
Selection.ShapeRange.ScaleWidth 0.55, msoFalse, msoScaleFromBottomRight 'Multiplica el ancho por el nº
Selection.ShapeRange.ScaleHeight 0.55, msoFalse, msoScaleFromBottomRight 'Multiplica el alto por el nº
Selection.ShapeRange.IncrementLeft 34 'Para mover
Selection.ShapeRange.IncrementTop 21 'la imagen


Bueno, tenes para entretenerte...
De todas maneras si queres agregar codigo que no esta arriba, fácil: programate una macro en Excel, anda a editarla y despues pasate el codigo a VB. Espero que te sirva. Saludos