IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Probleme graphique Excel


Sujet :

Macros et VBA Excel

  1. #1
    Membre du Club
    Inscrit en
    Juin 2006
    Messages
    133
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 133
    Points : 54
    Points
    54
    Par défaut Probleme graphique Excel
    Jai un probleme lorsque jai deja un fichier Excel deja douvert et que mon application tente de creer un nouveau fichier Excel (avec graphique). Desole je suis un newbie avec les graphiques excel.

    mon code fait erreur a la ligne pointee (lorsquil tente de creer le graphique je crois):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
     
    Private Sub CreateExcelGraphOEE()
     
        Dim xlApp As Excel.Application
        Dim xlBook As Excel.Workbook
        Dim xlSheet As Excel.Worksheet
        Dim xlSheetstat As Excel.Worksheet
        Dim iloop As Integer
        Dim iColCounter As Integer
        Dim sRefExcel As String
        Dim sPivotTableSheetName As String
     
        Dim ExcelDLL As CubeExportExcelDll.clsExportExcel
        Dim rs As ADODB.Recordset
     
        On Error GoTo CreateExcelGraphOEE_Error
     
        Set ExcelDLL = New CubeExportExcelDll.clsExportExcel
        sRefExcel = ""
     
     
        Set xlApp = ExcelDLL.OpenExcel
        Set mvarExcelApplication = xlApp
     
        Set xlBook = xlApp.Workbooks.Add
     
        Set xlSheet = xlBook.Sheets.Add
     
        xlSheet.Name = mvarDataSheetName
     
        xlSheet.Activate
        sRefExcel = CVCell(1, 1) 'A1 reference for Title
     
        xlSheet.Range(sRefExcel) = mvarDataSheetName
        xlSheet.Range(sRefExcel).Font.Bold = True
        xlSheet.Range(sRefExcel).Font.Color = vbBlue
     
        xlSheet.Activate
     
        'Set ExcelDLL = New CubeExportExcelDll.clsExportExcel
        ExcelDLL.LetRecordsetData mvarGraphRecordset
        sRefExcel = CVCell(2, 1) 'A1 reference for Data
        ExcelDLL.DirectExport xlBook.Name, xlSheet.Name, sRefExcel, True, True,   False, True
     
           xlApp.Range("F7").Select
     
        xlApp.ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= "'" & mvarDataSheetName & "'!R2C1:R" & CStr(mvarGraphRecordset.RecordCount + 2) & "C" & CStr(mvarGraphRecordset.Fields.Count)).CreatePivotTable TableDestination:="", _ TableName:="PivotTable1"
     
        xlApp.ActiveSheet.Name = mvarGraphName
     
      --erreur ici-->  xlApp.ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(mvarGraphRecordset.Fields.Count, 1)
     
    xlApp.ActiveSheet.Cells(mvarGraphRecordset.Fields.Count, 1).Select
     
        xlApp.ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
     
    ...
    Erreur 27501 Desc: 91 Object variable or With block variable not set

    au secours!

  2. #2
    Expert éminent sénior

    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    3 317
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2005
    Messages : 3 317
    Points : 20 144
    Points
    20 144
    Par défaut
    bonjour

    ce n'est pas évident de répondre mais tu peux essayer de rempalcer

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TableDestination:=ActiveSheet.Cells(...
    par

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TableDestination:=xlApp.ActiveSheet.Cells(...


    michel

  3. #3
    Membre du Club
    Inscrit en
    Juin 2006
    Messages
    133
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 133
    Points : 54
    Points
    54
    Par défaut
    Citation Envoyé par SilkyRoad
    bonjour

    ce n'est pas évident de répondre mais tu peux essayer de rempalcer

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TableDestination:=ActiveSheet.Cells(...
    par

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TableDestination:=xlApp.ActiveSheet.Cells(...


    michel
    merci davoir repondu mais jai la meme erreur

Discussions similaires

  1. Probleme graphique excel
    Par six3116 dans le forum Excel
    Réponses: 9
    Dernier message: 29/09/2013, 11h04
  2. Peut on inserer une fonction dans un graphique excel ?
    Par Celia1303 dans le forum Excel
    Réponses: 2
    Dernier message: 08/11/2005, 09h09
  3. création graphique excel à partir VB6
    Par getea85 dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 06/10/2005, 14h59
  4. recuperer 1 graphique excel vers VB
    Par tomgrc dans le forum Macros et VBA Excel
    Réponses: 13
    Dernier message: 25/02/2005, 17h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo