s_kashiew
Messages postés5Date d'inscriptionvendredi 7 janvier 2005StatutMembreDernière intervention26 novembre 2008
-
5 mars 2007 à 03:47
s_kashiew
Messages postés5Date d'inscriptionvendredi 7 janvier 2005StatutMembreDernière intervention26 novembre 2008
-
5 mars 2007 à 09:46
Salut,
J'aimerai faire un chargement automatique d'un addin a l'ouverture d'un Excel.
Voici comment je procede:
'.:: Open Excel ::.
Set ExcelWbk = ExcelApp.Workbooks.Open(XlsFileName)
For Each ArmAddin In ExcelApp.AddIns
If ArmAddin.Name = "AddinName" Then
FlagArmAddin = True
End If
Next
'.:: Add Addin ::.
If FlagArmAddin = True Then
If ExcelApp.AddIns("AddinName").Installed = False Then
ExcelApp.AddIns("AddinName").Installed = True
End If
Else
ExcelApp.AddIns.Add(Path, True).Installed = True
End If
A la premiere execution, il commence par me dire ExcelApp.AddIns("AddinName").Installed = True alors que lors d'un pas a pas, dans le menu des Addins, mon Addin n'est pas charge.
Donc j'ai force Excel en mettant
'.:: Add Addin ::.
If FlagArmAddin = True Then
ExcelApp.AddIns("AddinName").Installed = False
ExcelApp.AddIns("AddinName").Installed = True
Else
ExcelApp.AddIns.Add(Path, True).Installed = True
End If
Et la, pour la ligne ExcelApp.AddIns("AddinName").Installed = True il me met
Run-time error '1004':
Unable to set the Installed property of the Addin class.
mortalino
Messages postés6786Date d'inscriptionvendredi 16 décembre 2005StatutMembreDernière intervention21 décembre 201118 5 mars 2007 à 08:40
Salut,
je t'ai fait qques modifs de rien du tout, et je viens de tester avec une de mes macro complémentaire et ça fonctionne bien :
Option Explicit
Private Sub Form_Load()
Dim ExcelApp As Excel.Application
Dim ExcelWbk As Excel.Workbook
Dim ArmAddin As Excel.AddIn
Dim FlagArmAddin As Boolean
Set ExcelApp = New Excel.Application
Set ExcelWbk = ExcelApp.Workbooks.Open("C:\Documents and
settings\mortalino\Bureau\Classeur1.xls")
ExcelApp.Visible = True
For Each ArmAddin In ExcelApp.AddIns
If ArmAddin.Name = "Fonctions_Nico.xla" Then ' rajoute l'extension ICI
FlagArmAddin = True: Exit For 'modif ICI (il faut sortir de la boucle,
End If ' sinon ton flag repassera à
False étant
Next '
donné qu'il y'a peut-être d'autres *.xla
'.:: Add Addin ::.
If FlagArmAddin = True Then
If ExcelApp.AddIns("Fonctions_Nico").Installed = False Then
ExcelApp.AddIns("Fonctions_Nico").Installed = True
End If
Else
ExcelApp.AddIns.Add("C:\Documents and
settings\mortalino\Bureau", True).Installed = True
End If
mortalino
Messages postés6786Date d'inscriptionvendredi 16 décembre 2005StatutMembreDernière intervention21 décembre 201118 5 mars 2007 à 08:44
Arghh, petite erreur de ma part ici :
'.:: Add Addin ::.
If FlagArmAddin = True Then
If ExcelApp.AddIns("Fonctions_Nico").Installed = False Then
ExcelApp.AddIns("Fonctions_Nico").Installed = True
End If
Else
ExcelApp.AddIns.Add("C:\Documents and
settings\mortalino\Bureau\NomAddin.xla", True).Installed = True
' oublie ici du nom
^^
End If