| 
	
		|  Autor | Tema: Listview A Excel (Aliner celda)  (Leído 10,069 veces) |  
	| 
			| 
					
						| TheGhost(Z) 
								
								 Desconectado 
								Mensajes: 230
								
								   | 
 
Holas, veran estoy exportando el contenido de un Listview a EXcel. Tengo un '' problema al Aliner las celdasIzqueirda, centrarm, derecha gracias por la yuda desde ya.. Private Sub ExportarListadoMSExcel()Dim AppExcel As Object
 Set AppExcel = CreateObject("Excel.application")
 With AppExcel
 .Visible = True
 .Workbooks.Add '' Agregamos un Libro Nuevo
 
 Dim nFila As Integer
 nFila = 1 '' Agregos los titulos a nuestra columnas
 .Cells(nFila, 1) = "Id"
 .Cells(nFila, 2) = "Pais"
 .Cells(nFila, 3) = "Estado"
 Dim i As Long
 For i = 1 To Me.ListView1.ListItems.Count
 nFila = nFila + 1
 .Cells(nFila, 1) = Me.ListView1.ListItems(i).Text
 .Cells(nFila, 2) = Me.ListView1.ListItems(i).ListSubItems(1).Text
 .Cells(nFila, 3) = Me.ListView1.ListItems(i).ListSubItems(2).Text
 Next i
 
 .range("A1:C1").Font.Bold = True
 .range("A1:C1").Interior.Color = RGB(192, 200, 200)
 .Cells.EntireColumn.AutoFit
 
 '' ************* ERROR AL ALINEAR ayuda porfa.. **********************
 .Range("C1").TextAlign = fmTextAlignCenter
 .Range("A1:H1").HorizontalAlignment = xlCenter
 .cell(1,).TextAlign = fmTextAlignCenter
 '' ************************************************
 
 .ActiveWorkbook.SaveAs App.Path & "listado.xls" ''Guardas la hoja actual
 
 End With
 
 End Sub
 
 |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  |  |  | 
			| 
					
						| TheGhost(Z) 
								
								 Desconectado 
								Mensajes: 230
								
								   | 
 
Hola si alguien sabe alinear una celda de excel desde vb. Me han pasado un codigo: .Range("B4:L4").HorizontalAlignment = TruePero no alinea nada.. |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  | 
			| 
					
						| Sancho.Mazorka 
								 
								
								 Desconectado 
								Mensajes: 480
								
								 
								Gamer & Programador
								
								
								
								
								
								     | 
 
Tu aqui tienes error en la linea que te voy a marcar, ya que si no existe un funcion te pide 1 parametro no puede colocarle 2, o colocar una "," sin poner el 2 parametro porque da error: Private Sub ExportarListadoMSExcel()Dim AppExcel As Object    Set AppExcel = CreateObject("Excel.application")With AppExcel    .Visible = True     .Workbooks.Add '' Agregamos un Libro Nuevo     Dim nFila As Integer    nFila = 1 '' Agregos los titulos a nuestra columnas    .Cells(nFila, 1) = "Id"    .Cells(nFila, 2) = "Pais"    .Cells(nFila, 3) = "Estado"    Dim i As Long    For i = 1 To Me.ListView1.ListItems.Count        nFila = nFila + 1        .Cells(nFila, 1) = Me.ListView1.ListItems(i).Text        .Cells(nFila, 2) = Me.ListView1.ListItems(i).ListSubItems(1).Text        .Cells(nFila, 3) = Me.ListView1.ListItems(i).ListSubItems(2).Text    Next i     .range("A1:C1").Font.Bold = True    .range("A1:C1").Interior.Color = RGB(192, 200, 200)    .Cells.EntireColumn.AutoFit     '' ************* ERROR AL ALINEAR ayuda porfa.. **********************    .Range("C1").TextAlign = fmTextAlignCenter    .Range("A1:H1").HorizontalAlignment = xlCenter    .cell(1,).TextAlign = fmTextAlignCenter 'ERORRRRRR  .cell(1,)  sacale la "," (coma)    '' ************************************************     .ActiveWorkbook.SaveAs App.Path & "listado.xls" ''Guardas la hoja actual End With End Sub
 y otra cosa, podes postear tu code, o pasarmelo, me interesa ayudarte y de paso me sirve a mi. rhcp_269@hotmail.com |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  | 
			| 
					
						| TheGhost(Z) 
								
								 Desconectado 
								Mensajes: 230
								
								   | 
 
Despues de buscar y buscar consegui esto.. Si quieren mas codecs lo sacan de las Macros que se hacen en MS Excel. Espero les sirva. Private Sub Form_Load()Dim AppExcel As Excel.Application
 Set AppExcel = CreateObject("Excel.Application")
 
 With AppExcel
 .Workbooks.Add
 
 'Formatos
 With .Range("A1")
 .Font.Size = 18
 .Value = "NUCLEAR SILO READY!"
 .Font.Bold = True
 .Font.Name = "Arial Narrow" ' , etc, etc
 End With
 
 ' alinear celda
 With .Range("C11")
 .HorizontalAlignment = xlLeft
 .VerticalAlignment = xlTop
 
 'Reducir hasta ajustar
 .ReadingOrder = xlContext
 .WrapText = True
 End With
 
 'Combinar celdas
 .Range("D14:E15").Merge
 
 
 'Auto ajustar
 .Range("B:B").EntireColumn.AutoFit
 ' Ancho de columnas
 .Range("C:C").ColumnWidth = 26.71
 .Range("D:D").ColumnWidth = 28.57
 .Range("E:E").ColumnWidth = 10.29
 
 'margenes de la hora de imprecion
 .Sheets("Hoja1").PageSetup.LeftMargin = Application.InchesToPoints(0.13)
 .Sheets("Hoja1").PageSetup.RightMargin = Application.InchesToPoints(0.13)
 .Sheets("Hoja1").PageSetup.TopMargin = Application.InchesToPoints(0.13)
 .Sheets("Hoja1").PageSetup.BottomMargin = Application.InchesToPoints(0.13)
 
 'Bordes
 .Range("D14:G15").Borders(xlEdgeTop).LineStyle = xlContinuous
 .Range("D14:G15").Borders(xlEdgeTop).Weight = xlThin
 
 .Range("D14:G15").Borders(xlEdgeBottom).LineStyle = xlContinuous
 .Range("D14:G15").Borders(xlEdgeBottom).Weight = xlThin
 
 .Range("D14:G15").Borders(xlEdgeLeft).LineStyle = xlContinuous
 .Range("D14:G15").Borders(xlEdgeLeft).Weight = xlThin
 
 .Range("D14:G15").Borders(xlEdgeRight).LineStyle = xlContinuous
 .Range("D14:G15").Borders(xlEdgeRight).Weight = xlThin
 
 'Proteger hoja (sin contraseña)
 .Sheets("Hoja1").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
 
 'Cambiar de nombre a la hoja
 .Sheets("Hoja1").Name = Format(2007, "0000000000")
 
 'Mostrar libro
 .Visible = True
 
 'Guardar libro
 .ActiveWorkbook.SaveAs App.Path & "LOL.xls"
 ' imprimir libro
 .Sheets("Hoja1").PrintOut Copies:=1, Collate:=True
 'cerrar
 .Quit
 Set AppExcel = Nothing
 End With
 End Sub
 |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  |  |  
 
	
 
 
				
					
						| Mensajes similares |  
						|  | Asunto | Iniciado por | Respuestas | Vistas | Último mensaje |  
						|   |   | programcion en excel. modificar valor en la misma celda Dudas Generales
 | josco | 0 | 3,152 |  11 Junio 2012, 07:30 am por josco
 |  
						|   |   | Como escribir en una celda de Excel desde otra celda Software
 | javier234- | 4 | 4,060 |  22 Junio 2012, 21:57 pm por maxtextla
 |  
						|   |   | Buscar palabra en celda Excel Programación General
 | Lain0x | 2 | 3,967 |  2 Diciembre 2013, 07:36 am por Lain0x
 |  
						|   |   | Fijar relleno de una celda de excel Software
 | Luish@o | 0 | 2,249 |  22 Abril 2015, 22:51 pm por Luish@o
 |  
						|   |   | Listview A Excel (copiar a un rango de celda) .NET (C#, VB.NET, ASP)
 | Ericks | 0 | 3,747 |  15 Septiembre 2017, 23:02 pm por Ericks
 |    |