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
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