Bordes en excel

Que tal, bueno mi pregunta es la siguiente:
Tengo el código siguiente en un botón de comando:
Private Sub Command1_Click()
Dim o_Excel As Object
Dim o_Libro As Object
Dim o_Hoja As Object
Dim i As Byte
'nueva instancia de excel
Set o_Excel = CreateObject("Excel.Application")
'SE CREA UN NUEVO LIBRO
Set o_Libro = o_Excel.Workbooks.Add
'SE ASIGNA A LA VARIABLE o_Hoja LA HOJA ACTIVA DE ACUERDO CON LA VERSION DE EXCEL
If Val(o_Excel.Application.Version) >= 8 Then '>=8 ES UNA VERSION DE EXCEL SUPERIOR A 97
Set o_Hoja = o_Excel.ActiveSheet
Else
Set o_Hoja = o_Excel 'EXCEL 97
End If
'titulos de las columnas
o_Hoja.Cells(1, 1) = "NOMBRE"
o_Hoja.Cells(1, 2) = "RECIBIDOS"
o_Hoja.Cells(1, 3) = "TRABAJADOS"
o_Hoja.Cells(1, 4) = "PENDIENTES"
o_Hoja.Cells(1, 5) = "ASIGNADO"
'formato al encabezado
With o_Excel
.Selection.CurrentRegion.Columns.AutoFit
.Selection.CurrentRegion.Rows.AutoFit
.Selection.CurrentRegion.Font.Name = "Arial"
.Selection.CurrentRegion.Font.fontstyle = "Negrita"
.Selection.CurrentRegion.Font.Size = 8
.Selection.CurrentRegion.Interior.ColorIndex = 15
.ActiveSheet.Range("A1:E1").Select
.Save
.Visible = True 'SE HACE VISIBLE EL LIBRO
End With
' se descargan las variables para liberar la memoría
Set o_Excel = Nothing
Set o_Libro = Nothing
'Set o_Hoja = o_Libro.Worksheets.Add ESTA LINEA SIRVE PARA AGREGAR HOJAS NUEVAS AL LIBRO
End Sub
me corre perfecto el problema es que necesito que me pinte los bordes en la hoja de excel podrias ayudarme
de antemano gracias

1 Respuesta

Respuesta
1
A ver si estas instrucciones te sirven
Sub Bordes()
Range("B3:F27").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
End Sub
Suerte !
gracias, pero ya intente eso, tal vez falto aclarar que lo estoy haciendo en Visual Basic 6.0 no en VBA...
Pues en Visual Basic 6.0 debería ser más o menos así:
HojaExcel.Aplication.ActiveSheet.Range("A1:E1").Select
With Hojaexcel.Aplication.Selection.Border
.Colorindex = 4
.LineStyle = 1
End With
Suerte

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas