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

VBA Access Discussion :

VBA Access probleme de renvoi


Sujet :

VBA Access

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 226
    Points : 72
    Points
    72
    Par défaut VBA Access probleme de renvoi
    Bonjour
    j'ai un probleme de renvoie
    Pour le moment ma fonction renvoie le classeur mais j'aimerais aussi renvoyer l'objet Excel.Application (car si je l'ouvre deux fois ca va pas le faire) donc je vois pas comment envoyer les deux en meme temps pour l'instant ma fonction est constitué comme cela
    Merci d'avance
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    Public Function MacroTest(c As Integer) As Workbook
     
    'Déclarations des variables
    Set xls = New Excel.Application
    Dim name As String
    Dim Classeur As Workbook
    'Ouverture du tableau Excel
        xls.Visible = True
        Set Classeur = xls.Workbooks.Open("D:\Test\e_analyse_croisée_Test.xls")
     ...
    Set MacroTest = Classeur

  2. #2
    Nouveau membre du Club
    Inscrit en
    Novembre 2006
    Messages
    28
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 28
    Points : 27
    Points
    27
    Par défaut
    Le but de ta fonction c'est quoi Ouvrir ou "Recuperer" le classeur?

    Parce que tel qu'il est ecrit ton code est plutot fait pour Ouvrir le classeur.

    Donc mettre ce code dans une Function ne sert pas a grand chose

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    j'aimerais renvoyer aussi l'application excel que j'utilise

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    voila ma ligne d'entrée
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    module2.Macro1(wbfile,appli)
    et ma fonction il me renvoie rien que je sache
    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
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    Option Compare Database
     
    Option Explicit
     
    Public Sub Macro1(wbfile As Workbook, xls As Excel.Application)
     
    '
    ' Macro1 Macro
    ' Macro enregistrée le 14/06/2007 par
    '
     
    '
        Dim graph As Chart
        Set graph = wbfile.Charts.Add
     
     
        graph.SeriesCollection(1).ChartType = xlColumnStacked
        graph.SeriesCollection.NewSeries
        graph.SeriesCollection(1).XValues = "=R_analyse_croisée!R3C2:R4C10"
        graph.SeriesCollection(1).name = "=R_analyse_croisée!R53C1"
        graph.SeriesCollection(2).XValues = "=R_analyse_croisée!R3C2:R4C10"
        graph.SeriesCollection(2).name = "=R_analyse_croisée!R54C1"
        graph.SeriesCollection(3).XValues = "=R_analyse_croisée!R3C2:R4C10"
        graph.SeriesCollection(3).Values = "=R_analyse_croisée!R48C2:R48C10"
        graph.SeriesCollection(3).Select
        graph.SeriesCollection(3).ChartType = xlXYScatter
        With graph.SeriesCollection(3).Border
            .Weight = xlHairline
            .LineStyle = xlNone
        End With
        With graph.SeriesCollection(3)
            .MarkerBackgroundColorIndex = xlAutomatic
            .MarkerForegroundColorIndex = xlAutomatic
            .MarkerStyle = xlNone
            .Smooth = False
            .MarkerSize = 5
            .Shadow = False
        End With
        graph.SeriesCollection(3).ApplyDataLabels AutoText:=True, LegendKey:=False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=True, ShowPercentage:=False, ShowBubbleSize:=False
        graph.SeriesCollection(3).DataLabels.Select
        graph.SeriesCollection(3).Points(1).DataLabel.Left = 50
        graph.SeriesCollection(3).Points(1).DataLabel.Top = 158
        graph.SeriesCollection(3).Points(2).DataLabel.Left = 114
        graph.SeriesCollection(3).Points(2).DataLabel.Top = 76
        graph.SeriesCollection(3).Points(3).DataLabel.Left = 178
        graph.SeriesCollection(3).Points(3).DataLabel.Top = 64
        graph.SeriesCollection(3).Points(4).DataLabel.Left = 243
        graph.SeriesCollection(3).Points(4).DataLabel.Top = 23
        graph.SeriesCollection(3).Points(5).DataLabel.Left = 306
        graph.SeriesCollection(3).Points(5).DataLabel.Top = 45
        graph.SeriesCollection(3).Points(6).DataLabel.Left = 371
        graph.SeriesCollection(3).Points(6).DataLabel.Top = 148
        graph.SeriesCollection(3).Points(7).DataLabel.Left = 436
        graph.SeriesCollection(3).Points(7).DataLabel.Top = 123
        graph.SeriesCollection(3).Points(8).DataLabel.Left = 504
        graph.SeriesCollection(3).Points(8).DataLabel.Top = 328
        graph.SeriesCollection(3).Points(9).DataLabel.Left = 569
        graph.SeriesCollection(3).Points(9).DataLabel.Top = 312
        With graph.SeriesCollection(2).Border
            .Weight = xlThin
            .LineStyle = xlAutomatic
        End With
        graph.SeriesCollection(2).Shadow = False
        graph.SeriesCollection(2).InvertIfNegative = False
        With graph.SeriesCollection(2).Interior
            .ColorIndex = 37
            .Pattern = xlSolid
        End With
        graph.SeriesCollection(2).ApplyDataLabels AutoText:=True, LegendKey:=False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=True, ShowPercentage:=False, ShowBubbleSize:=False
        With graph.SeriesCollection(1).Border
            .Weight = xlThin
            .LineStyle = xlAutomatic
        End With
        graph.SeriesCollection(1).Shadow = False
        graph.SeriesCollection(1).InvertIfNegative = False
        With graph.SeriesCollection(1).Interior
            .ColorIndex = 10
            .Pattern = xlSolid
        End With
        graph.SeriesCollection(1).ApplyDataLabels AutoText:=True, LegendKey:=False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=True, ShowPercentage:=False, ShowBubbleSize:=False
        With graph.PlotArea.Border
            .ColorIndex = 16
            .Weight = xlThin
            .LineStyle = xlContinuous
        End With
        With graph.PlotArea.Interior
            .ColorIndex = 2
            .PatternColorIndex = 1
            .Pattern = xlSolid
        End With
        With graph.SeriesCollection(3).DataLabels.Border
            .Weight = xlHairline
            .LineStyle = xlNone
        End With
        graph.SeriesCollection(3).DataLabels.Shadow = False
        graph.SeriesCollection(3).DataLabels.Interior.ColorIndex = xlNone
        graph.SeriesCollection(3).Points(2).DataLabel.Select
        graph.SeriesCollection(3).Points(1).DataLabel.Select
        graph.SeriesCollection(3).DataLabels.AutoScaleFont = True
        With graph.SeriesCollection(3).DataLabels.Font
            .name = "Arial"
            .FontStyle = "Gras"
            .Size = 10
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = 3
            .Background = xlAutomatic
        End With
        graph.SeriesCollection(2).DataLabels.AutoScaleFont = True
        With graph.SeriesCollection(2).DataLabels.Font
            .name = "Arial"
            .FontStyle = "Gras"
            .Size = 10
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        graph.SeriesCollection(1).DataLabels.AutoScaleFont = True
        With graph.SeriesCollection(1).DataLabels.Font
            .name = "Arial"
            .FontStyle = "Gras"
            .Size = 10
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        graph.Legend.LegendEntries(3).Delete
        graph.Legend.Left = 35
        graph.Legend.Top = 25
        graph.Legend.Width = 99
        graph.Legend.Width = 107
     
    End Sub

  5. #5
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Points : 24 327
    Points
    24 327
    Par défaut
    A quoi cela te servirait-il de "renvoyer" l'application?

    A quoi te sert ton c comme paramètre de ta fonction? Tu ne l'utilises pas.
    N'oubliez pas de cliquer sur quand vous avez obtenu ou trouvé vous-même la réponse à votre question.
    Si vous trouvez seul, pensez à poster votre solution. Elle peut servir à d'autres!
    Pensez aussi à voter pour les réponses qui vous ont aidés.
    ------------
    Je dois beaucoup de mes connaissances à mes erreurs!

Discussions similaires

  1. VBA ACCESS probleme avec une boucle for
    Par maldini dans le forum VBA Access
    Réponses: 2
    Dernier message: 20/04/2010, 09h52
  2. Réponses: 8
    Dernier message: 24/05/2007, 18h09
  3. VBA Access Probleme de compilation
    Par darkspoilt dans le forum VBA Access
    Réponses: 6
    Dernier message: 10/05/2007, 17h16
  4. probleme Vba access
    Par pietra5 dans le forum Access
    Réponses: 2
    Dernier message: 25/10/2006, 04h31
  5. [vba-access] probleme avec word.application
    Par realthunderbolt dans le forum Access
    Réponses: 3
    Dernier message: 23/08/2006, 19h02

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