Visual Basic - Ancho de columnas Excel!!!

Life is soft - evento anual de software empresarial
 
Vista:

Ancho de columnas Excel!!!

Publicado por cerb (675 intervenciones) el 15/02/2005 16:54:33
Amigos alguien sabe como dar ancho a las columnas del Excel desde Visual Basic, mandenme un ejemplo porfavor urgente, agradezco sus respuestas. bye.
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:Ancho de columnas Excel!!!

Publicado por miguel (1042 intervenciones) el 15/02/2005 17:06:02
Puede haber dos formas de hacerlo:
Dim xlApp As Excel.Application
Dim mySheet As Excel.Worksheet
Sub LlenaLista()
On Error GoTo Errores
Dim vlRuta As String
Dim I As Integer
Set xlApp = CreateObject("Excel.Application")
vlRuta = App.Path & "\cpsp.xls"
xlApp.Workbooks.Open vlRuta
Set mySheet = xlApp.ActiveSheet
'1ra.
For Each col In mySheet.Columns
If col.Column Mod 2 = 0 Then
col.ColumnWidth = 10
End If
Next col
'2da.
mySheet.Range("A1:E1").ColumnWidth = 4

xlApp.DisplayAlerts = False 'permite sobreescribir sin preguntar
xlApp.ActiveWorkbook.Save

MsgBox "Proceso Terminado", vbInformation
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