Macro Add-In

jbdubreuil

XLDnaute Occasionnel
Bonjour le forum,

Je travaille sur un programme qui utilise un code VBA pour des extractions de données. Ce programme est un "add-in" avec des boutons pour updater le fichier suivant les dimensions choisies.

J'aimerais ajouter une macro qui lance automatiquement à la suite une liste pour une dimension. (par exemple obtenir les resultats de janvier à mai)

Mais ca ne marche pas, j'ai besoin de clicker sur le bouton "Download" (CFD)
J'ai le code ci dessous, mais ne suis pas un expert en language VBA.
Quelle partie du code ai je besoin pour pour lancer l'application add in (calcul CFD)

Je sais que c'est tres difficile, et n'espere donc qu'un miracle.

Merci par avance pour votre soutient

Amicalement,

Jean-Baptiste




Dim CFobj As Object
Private Const str_Addin = "CFXL.Connect" '--1st part MUST BE the DLL name
Private Const str_Color_Default = "S" '=Statement
Private Const str_Switch_Default = "M" '=Monthly
Private Const str_Scale_Default = "0" '=no scaling
Private Const str_Name_Default = "<?>"
Private Const str_Last_Default = "<?>"

Private Function GetCFobj() As Boolean
On Error Resume Next
GetCFobj = False
If CFobj Is Nothing Then
Set CFobj = Excel.Application.COMAddIns.Item((str_Addin)).Object.Formulas
End If
If Not CFobj Is Nothing Then GetCFobj = True
End Function

Public Sub DeleteHelpComment()
Dim shp As Variant
For Each shp In Excel.ActiveSheet.Shapes
If shp.Name = "CFXL" Then shp.Delete
Next shp
End Sub

Public Function CFD(Submissions As String, Company As String, Channels As String, Product As String, Accounts As String, Periods As String, _
Optional fColor As String = str_Color_Default, _
Optional fSwitch As String = str_Switch_Default, _
Optional fScale As Variant = str_Scale_Default, _
Optional Value As Variant = 0) As Variant
On Error GoTo Err
Dim CellAddr As String
CFD = Value
If Not GetCFobj() Then Exit Function
CellAddr = Excel.Application.Caller.Address(False, False, xlA1, True)
CFD = CFobj.CFD(CellAddr, Submissions, Company, Channels, Product, Accounts, Periods, "", "", "", "", "", "", "", "", "", fColor, fSwitch, CStr(fScale), Value)
Err:
End Function

Public Function CFI(Submissions As String, Company As String, Channels As String, Product As String, Accounts As String, Periods As String, _
Optional fColor As String = str_Color_Default, _
Optional fSwitch As String = str_Switch_Default, _
Optional fScale As Variant = str_Scale_Default, _
Optional Value As Variant = 0) As Variant
On Error GoTo Err
Dim CellAddr As String
CFI = Value
If Not GetCFobj() Then Exit Function
CellAddr = Excel.Application.Caller.Address(False, False, xlA1, True)
CFI = CFobj.CFI(CellAddr, Submissions, Company, Channels, Product, Accounts, Periods, "", "", "", "", "", "", "", "", "", fColor, fSwitch, CStr(fScale), Value)
Err:
End Function

Public Function CFDIC(Submissions As String, Company As String, Channels As String, Product As String, Accounts As String, Periods As String, Optional Target_Company As String, Optional Target_Channels As String, Optional Target_Product As String, _
Optional fColor As String = str_Color_Default, _
Optional fSwitch As String = str_Switch_Default, _
Optional fScale As Variant = str_Scale_Default, _
Optional Value As Variant = 0) As Variant
On Error GoTo Err
Dim CellAddr As String
CFDIC = Value
If Not GetCFobj() Then Exit Function
CellAddr = Excel.Application.Caller.Address(False, False, xlA1, True)
CFDIC = CFobj.CFDIC(CellAddr, Submissions, Company, Channels, Product, Accounts, Periods, Target_Company, Target_Channels, Target_Product, "", "", "", "", "", "", fColor, fSwitch, CStr(fScale), Value)
Err:
End Function

Public Function CFIIC(Submissions As String, Company As String, Channels As String, Product As String, Accounts As String, Periods As String, Optional Target_Company As String, Optional Target_Channels As String, Optional Target_Product As String, _
Optional fColor As String = str_Color_Default, _
Optional fSwitch As String = str_Switch_Default, _
Optional fScale As Variant = str_Scale_Default, _
Optional Value As Variant = 0) As Variant
On Error GoTo Err
Dim CellAddr As String
CFIIC = Value
If Not GetCFobj() Then Exit Function
CellAddr = Excel.Application.Caller.Address(False, False, xlA1, True)
CFIIC = CFobj.CFIIC(CellAddr, Submissions, Company, Channels, Product, Accounts, Periods, Target_Company, Target_Channels, Target_Product, "", "", "", "", "", "", fColor, fSwitch, CStr(fScale), Value)
Err:
End Function



Public Function CFNAME(Dimension As Variant, ID As String, _
Optional Value As String = str_Name_Default) As Variant
On Error GoTo Err
Dim CellAddr As String
CFNAME = Value
If Not GetCFobj() Then Exit Function
CellAddr = Excel.Application.Caller.Address(False, False, xlA1, True)
CFNAME = CFobj.CFNAME(CellAddr, Dimension, ID, Value)
Err:
End Function

Public Function CFLastUpdate() As Variant
On Error GoTo Err
Dim CellAddr As String
If Not GetCFobj() Then Exit Function
CellAddr = Excel.Application.Caller.Address(False, False, xlA1, True)
CFLastUpdate = CFobj.CFLastUpdate(CellAddr)
If CFLastUpdate = "" Then CFLastUpdate = str_Last_Default
Err:
End Function
 
C

Compte Supprimé 979

Guest
Re : Macro Add-In

Salut Jbdubreuil,

Le code que tu nous as mis ne contient que des fonctions (Public Function / End Function) !

Si tu clique sur un bouton, tu as forcément une "Sub" quelque part.
Il faut donc déjà touver ce code !

A+
 

jbdubreuil

XLDnaute Occasionnel
Re : Macro Add-In

Le forum, Bruno,

Merci pour ta reponse.
Le bouton en question est sur la barre d'outil d'excel.
C'est bizarre puisque:
1) je n'ai rien comme sub ou comme code dans VBA project autre que celui donné precedemment.
2) lorsque je regarde dans les add-in, je n'ai pas l'add in en question.

J'imagine que tout cela doit etre sur le serveur.
Je vais essayer de trouver qqchose.

Merci en tous les cas,

JB
 

Statistiques des forums

Discussions
315 138
Messages
2 116 685
Membres
112 836
dernier inscrit
MOHAMED69