Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2006, 01:51 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to I_See
Default Problems with CurrentRegions (Excel) in VB6

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









Similar Threads
Thread Thread Starter Forum Replies Last Post
Working with Excel from VB6 program aarmit10 Pro VB 6 0 March 17th, 2006 06:36 AM
VB6/Excel/SQL tmiller1 Excel VBA 2 April 6th, 2005 02:10 PM
Database problems with mySQL and VB6 rgtuplin Pro VB 6 3 February 4th, 2004 04:06 PM
Problems Installing VB6 app developed in XP on NT chiefouko VB Databases Basics 16 November 10th, 2003 08:29 AM
How can i open Excel From VB6 chiefouko Beginning VB 6 1 June 30th, 2003 08:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.