Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2787 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  VBA Access probleme de renvoi

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

VBA Access probleme de renvoi

n°1576168
darkspoilt
Posté le 18-06-2007 à 11:17:54  profilanswer
 

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é kom cela
Merci d'avance

Code :
  1. Public Function MacroTest(c As Integer) As Workbook
  2. 'Déclarations des variables
  3. Set xls = New Excel.Application
  4. Dim name As String
  5. Dim Classeur As Workbook
  6. 'Ouverture du tableau Excel
  7.     xls.Visible = True
  8.     Set Classeur = xls.Workbooks.Open("D:\Test\e_analyse_croisée_Test.xls" )
  9. ...
  10. Set MacroTest = Classeur


mood
Publicité
Posté le 18-06-2007 à 11:17:54  profilanswer
 

n°1576205
jpcheck
Pioupiou
Posté le 18-06-2007 à 12:01:55  profilanswer
 

je vois pas l'intéret de ta macro en fait...
tu peux expliciter un peu stp ?

n°1576232
darkspoilt
Posté le 18-06-2007 à 13:25:05  profilanswer
 

ma macro ouvre un objet Excel.Application elle créer un classeur que je renvoi le truc c'est que apres lorsque j'ai des action a faire dans un autre module, je ne vais pas ouvrir de nouveau un objet Excel.Application.

n°1576233
jpcheck
Pioupiou
Posté le 18-06-2007 à 13:26:42  profilanswer
 

et pourquoi ne passes tu pas en parametre dans ta première fonction appelante un path pour enregistrer ton document, que tu utilises à nouveau dans les autres fonctions de traitement.

n°1576235
darkspoilt
Posté le 18-06-2007 à 13:30:43  profilanswer
 

sinon quelqu'un peut m'expliquer les byref
Losque je marque ca pkoi il attend un "=" dans ma fonction principale??

Code :
  1. Public Sub Macro1(ByRef wbfile As Excel.Workbook, Byref xls as Excel.application)


Message édité par darkspoilt le 18-06-2007 à 13:36:48
n°1576238
darkspoilt
Posté le 18-06-2007 à 13:39:19  profilanswer
 

je n'utilise pas les path car je débute en VBA

n°1576243
jpcheck
Pioupiou
Posté le 18-06-2007 à 13:45:23  profilanswer
 

vire le public
 
le path, ce n'est rien qu'un string  :love:  
tu te créer une variable
temp = format(now(),"ddMMyyyyhhmmss" ) & ".xls"
tu balances
Ma_sub_de_traitement(temp)

n°1576246
darkspoilt
Posté le 18-06-2007 à 13:51:05  profilanswer
 

oui mais ca changera pas grand chose a mon probleme

n°1576252
darkspoilt
Posté le 18-06-2007 à 13:55:22  profilanswer
 

voila ma ligne d'entrée

Code :
  1. module2.Macro1(wbfile,appli)


 
et mon code complet
 

Code :
  1. Option Compare Database
  2. Option Explicit
  3. Public Sub Macro1(wbfile As Workbook, xls As Excel.Application)
  4. '
  5. ' Macro1 Macro
  6. ' Macro enregistrée le 14/06/2007 par
  7. '
  8. '
  9.     Dim graph As Chart
  10.     Set graph = wbfile.Charts.Add
  11.    
  12.     graph.SeriesCollection(1).ChartType = xlColumnStacked
  13.     graph.SeriesCollection.NewSeries
  14.     graph.SeriesCollection(1).XValues = "=R_analyse_croisée!R3C2:R4C10"
  15.     graph.SeriesCollection(1).name = "=R_analyse_croisée!R53C1"
  16.     graph.SeriesCollection(2).XValues = "=R_analyse_croisée!R3C2:R4C10"
  17.     graph.SeriesCollection(2).name = "=R_analyse_croisée!R54C1"
  18.     graph.SeriesCollection(3).XValues = "=R_analyse_croisée!R3C2:R4C10"
  19.     graph.SeriesCollection(3).Values = "=R_analyse_croisée!R48C2:R48C10"
  20.     graph.SeriesCollection(3).Select
  21.     graph.SeriesCollection(3).ChartType = xlXYScatter
  22.     With graph.SeriesCollection(3).Border
  23.         .Weight = xlHairline
  24.         .LineStyle = xlNone
  25.     End With
  26.     With graph.SeriesCollection(3)
  27.         .MarkerBackgroundColorIndex = xlAutomatic
  28.         .MarkerForegroundColorIndex = xlAutomatic
  29.         .MarkerStyle = xlNone
  30.         .Smooth = False
  31.         .MarkerSize = 5
  32.         .Shadow = False
  33.     End With
  34.     graph.SeriesCollection(3).ApplyDataLabels AutoText:=True, LegendKey:=False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=True, ShowPercentage:=False, ShowBubbleSize:=False
  35.     graph.SeriesCollection(3).DataLabels.Select
  36.     graph.SeriesCollection(3).Points(1).DataLabel.Left = 50
  37.     graph.SeriesCollection(3).Points(1).DataLabel.Top = 158
  38.     graph.SeriesCollection(3).Points(2).DataLabel.Left = 114
  39.     graph.SeriesCollection(3).Points(2).DataLabel.Top = 76
  40.     graph.SeriesCollection(3).Points(3).DataLabel.Left = 178
  41.     graph.SeriesCollection(3).Points(3).DataLabel.Top = 64
  42.     graph.SeriesCollection(3).Points(4).DataLabel.Left = 243
  43.     graph.SeriesCollection(3).Points(4).DataLabel.Top = 23
  44.     graph.SeriesCollection(3).Points(5).DataLabel.Left = 306
  45.     graph.SeriesCollection(3).Points(5).DataLabel.Top = 45
  46.     graph.SeriesCollection(3).Points(6).DataLabel.Left = 371
  47.     graph.SeriesCollection(3).Points(6).DataLabel.Top = 148
  48.     graph.SeriesCollection(3).Points(7).DataLabel.Left = 436
  49.     graph.SeriesCollection(3).Points(7).DataLabel.Top = 123
  50.     graph.SeriesCollection(3).Points(8).DataLabel.Left = 504
  51.     graph.SeriesCollection(3).Points(8).DataLabel.Top = 328
  52.     graph.SeriesCollection(3).Points(9).DataLabel.Left = 569
  53.     graph.SeriesCollection(3).Points(9).DataLabel.Top = 312
  54.     With graph.SeriesCollection(2).Border
  55.         .Weight = xlThin
  56.         .LineStyle = xlAutomatic
  57.     End With
  58.     graph.SeriesCollection(2).Shadow = False
  59.     graph.SeriesCollection(2).InvertIfNegative = False
  60.     With graph.SeriesCollection(2).Interior
  61.         .ColorIndex = 37
  62.         .Pattern = xlSolid
  63.     End With
  64.     graph.SeriesCollection(2).ApplyDataLabels AutoText:=True, LegendKey:=False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=True, ShowPercentage:=False, ShowBubbleSize:=False
  65.     With graph.SeriesCollection(1).Border
  66.         .Weight = xlThin
  67.         .LineStyle = xlAutomatic
  68.     End With
  69.     graph.SeriesCollection(1).Shadow = False
  70.     graph.SeriesCollection(1).InvertIfNegative = False
  71.     With graph.SeriesCollection(1).Interior
  72.         .ColorIndex = 10
  73.         .Pattern = xlSolid
  74.     End With
  75.     graph.SeriesCollection(1).ApplyDataLabels AutoText:=True, LegendKey:=False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=True, ShowPercentage:=False, ShowBubbleSize:=False
  76.     With graph.PlotArea.Border
  77.         .ColorIndex = 16
  78.         .Weight = xlThin
  79.         .LineStyle = xlContinuous
  80.     End With
  81.     With graph.PlotArea.Interior
  82.         .ColorIndex = 2
  83.         .PatternColorIndex = 1
  84.         .Pattern = xlSolid
  85.     End With
  86.     With graph.SeriesCollection(3).DataLabels.Border
  87.         .Weight = xlHairline
  88.         .LineStyle = xlNone
  89.     End With
  90.     graph.SeriesCollection(3).DataLabels.Shadow = False
  91.     graph.SeriesCollection(3).DataLabels.Interior.ColorIndex = xlNone
  92.     graph.SeriesCollection(3).Points(2).DataLabel.Select
  93.     graph.SeriesCollection(3).Points(1).DataLabel.Select
  94.     graph.SeriesCollection(3).DataLabels.AutoScaleFont = True
  95.     With graph.SeriesCollection(3).DataLabels.Font
  96.         .name = "Arial"
  97.         .FontStyle = "Gras"
  98.         .Size = 10
  99.         .Strikethrough = False
  100.         .Superscript = False
  101.         .Subscript = False
  102.         .OutlineFont = False
  103.         .Shadow = False
  104.         .Underline = xlUnderlineStyleNone
  105.         .ColorIndex = 3
  106.         .Background = xlAutomatic
  107.     End With
  108.     graph.SeriesCollection(2).DataLabels.AutoScaleFont = True
  109.     With graph.SeriesCollection(2).DataLabels.Font
  110.         .name = "Arial"
  111.         .FontStyle = "Gras"
  112.         .Size = 10
  113.         .Strikethrough = False
  114.         .Superscript = False
  115.         .Subscript = False
  116.         .OutlineFont = False
  117.         .Shadow = False
  118.         .Underline = xlUnderlineStyleNone
  119.         .ColorIndex = xlAutomatic
  120.         .Background = xlAutomatic
  121.     End With
  122.     graph.SeriesCollection(1).DataLabels.AutoScaleFont = True
  123.     With graph.SeriesCollection(1).DataLabels.Font
  124.         .name = "Arial"
  125.         .FontStyle = "Gras"
  126.         .Size = 10
  127.         .Strikethrough = False
  128.         .Superscript = False
  129.         .Subscript = False
  130.         .OutlineFont = False
  131.         .Shadow = False
  132.         .Underline = xlUnderlineStyleNone
  133.         .ColorIndex = xlAutomatic
  134.         .Background = xlAutomatic
  135.     End With
  136.     graph.Legend.LegendEntries(3).Delete
  137.     graph.Legend.Left = 35
  138.     graph.Legend.Top = 25
  139.     graph.Legend.Width = 99
  140.     graph.Legend.Width = 107
  141.    
  142. End Sub


Message édité par darkspoilt le 18-06-2007 à 14:00:08
n°1576264
jpcheck
Pioupiou
Posté le 18-06-2007 à 14:02:16  profilanswer
 

a quoi ca te sert de renvoyer le workbook ? tu te contentesde l'enregistrer dans ta fonction précédente, et tu l'ouvres à nouveau dans ta 2e fonction...

mood
Publicité
Posté le 18-06-2007 à 14:02:16  profilanswer
 

n°1576272
darkspoilt
Posté le 18-06-2007 à 14:11:44  profilanswer
 

justement je veux pas l'enregister

n°1576285
jpcheck
Pioupiou
Posté le 18-06-2007 à 14:27:09  profilanswer
 

même en temporaire ? tu peux faire un .delete à la fin sinon... :pt1cable:

n°1576295
darkspoilt
Posté le 18-06-2007 à 14:31:48  profilanswer
 

non mais c'est bon je fais un wall macro ca marche nikel juste dans ma macro1
cette ligne ne fonctionne pas et je ne sais pas pkoi

Code :
  1. xls.wbfile.Worksheet("R_analyse_croisée" ).Range("A1" ).Select

n°1576301
jpcheck
Pioupiou
Posté le 18-06-2007 à 14:35:36  profilanswer
 

un s a worksheets peut être ?

n°1576303
darkspoilt
Posté le 18-06-2007 à 14:37:05  profilanswer
 

non ce n'est pas ca

n°1576306
darkspoilt
Posté le 18-06-2007 à 14:48:43  profilanswer
 

personne peut m'aider??

n°1576321
darkspoilt
Posté le 18-06-2007 à 15:09:46  profilanswer
 

j'ai fais wbfile.Worksheet("R_analyse_croisée" ).Range("A1" ).Select mais cela ne fonctionne pas il me met propriété ou méthode non géré


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  VBA Access probleme de renvoi

 

Sujets relatifs
VBA Access porbleme méthode objetProblème pour additionner des variables
[J2ME] Problème flux mjpegLe déroulement d'un menu qui passe sous un bloc, probléme!
Probleme avec HashmapProbléme VALUES formulaire
Problème avec le curseurProbleme session combiné aux frames
Access - Liste déroulantes Dépendantes ... 
Plus de sujets relatifs à : VBA Access probleme de renvoi


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR