Visual Basic - Ancho de columas Excel

Life is soft - evento anual de software empresarial
 
Vista:

Ancho de columas Excel

Publicado por Cerb (675 intervenciones) el 15/02/2005 16:19:52
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 columas Excel

Publicado por miguel (1042 intervenciones) el 15/02/2005 16:57:07
Prueba con esto:
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

For Each col In mySheet.Columns
If col.Column Mod 2 = 0 Then
col.ColumnWidth = 4
End If
Next col

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

RE:Ancho de columas Excel(otra manera)

Publicado por miguel (1042 intervenciones) el 15/02/2005 17:04:14
Ejemplo:
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

mySheet.Range("A1:D1").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

RE:Ancho de columas Excel(otra manera)

Publicado por Christian (675 intervenciones) el 15/02/2005 17:11:43
creo que esta es mejor, se agradece Miguel.
Saludos.
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