Hello,
I am trying to create a dynamic table in a book of Excel, from an application in VB6, but I have problems with the following code:
Private Function LlenarHojaLev() As Boolean
On Error GoTo ManejoError
LlenarHojaLev = False
Dim sPagina As String ' Para almacenar el nombre de la variable de página en la tabla dinámica
Dim sColumna As String ' Para almacenar el nombre de la variable de columna en la tabla dinámica
Dim sFila As String ' Para almacenar el nombre de la variable de fila en la tabla dinámica
Dim iFilas As Integer ' Para alamacenar el número de filas de la región seleccionada
Set objExcel = CreateObject("EXCEL.APPLICATION")
Set oLibro = objExcel.Workbooks.Add(App.Path & "\Pruebas.xls")
sPagina = "COLOR"
sColumna = "VARIEDAD"
sFila = "CLIMA"
Set oHoja = oLibro.Worksheets.Item(1)
With oHoja
Set oRango = .range("A2")
oRango.currentregion.rows.Count
iFilas = oRango.currentregion.rows.Count
.PivotCaches.Add(SourceType:=1, SourceData:= _
"Datos_Levante!R8C1:R" & iFilas & "C27").CreatePivotTable TableDestination:="", TableName:= _
"Agrupados Levante", DefaultVersion:=-1
.PivotTableWizard TableDestination:=.Cells(3, 1)
.Cells(3, 1).Select
.PivotTables("Agrupados Levante").AddFields RowFields:=sFila, _
ColumnFields:=sColumna, PageFields:=sPagina
.PivotTables("Agrupados Levante").PivotFields("Kgr Semana"). _
Orientation = 4
End With
but in the sentence
.PivotCaches.Add(SourceType:=1, SourceData:= _
"Datos_Levante!R8C1:R" & iFilas & "C27").CreatePivotTable TableDestination:="", TableName:= _
"Agrupados Levante", DefaultVersion:=0
since it shows the following error:
Object doesn't support this property or method
and nonencounter the problem, since if I execute it with early binding if it works.
thanks for its aid