Ver Mensaje Individual
  #7 (permalink)  
Antiguo 14/08/2013, 12:48
darkprogrammer
 
Fecha de Ingreso: octubre-2012
Ubicación: Piedras Negras
Mensajes: 8
Antigüedad: 11 años, 6 meses
Puntos: 0
Respuesta: Proyecto VB Studio 2010 para Excel

Después de mucho buscar, encontré la solución no se si sea la mas práctica pero me funciona.

Fuente: [URL="http://visualstudiomagazine.com/articles/2011/06/20/wcovb_automate-excel/wcovb_listing-2.aspx"]http://visualstudiomagazine.com/articles/2011/06/20/wcovb_automate-excel/wcovb_listing-2.aspx[/URL]

Así quedó mi código:

Código vb:
Ver original
  1. Public Function loadData(ByVal datos)
  2.         Dim xlApp As Excel.Application = New Excel.Application
  3.         xlApp.ScreenUpdating = False
  4.         Dim INCData As Excel.Worksheet = CType(Globals.ThisWorkbook.Sheets(2), Excel.Worksheet)
  5.         If datos = "INC" Then
  6.             xlFila = 2
  7.             xlColumna = 1
  8.             With INCData
  9.                 .Activate()
  10.                 .Range(.Range("A2"), .Range("S2").End(Excel.XlDirection.xlDown)).Clear()
  11.                 numReg = UBound(Rs.GetRows(), 2) + 1
  12.                 Rs.MoveFirst()
  13.                 While Not Rs.EOF
  14.                     xlColumna = 1
  15.                     For i = 0 To Rs.Fields.Count - 1
  16.                         .Cells(xlFila, xlColumna) = Rs(i).Value
  17.                         xlColumna = xlColumna + 1
  18.                     Next i
  19.                     xlFila = xlFila + 1
  20.                     Rs.MoveNext()
  21.                 End While
  22.             End With
  23.         Else
  24.             'ACCIONES CUANDO SON WO
  25.        End If
  26.     End Function

Pero... Ahora no me funciona el screenupdate = false no quiero que se vea todo el cambio de hojas y cálculos que se van a hacer.

¿Alguna idea?

Saludos,
Erick.