Macro Excel 2013 qui ne fonctionne pas sous Excel 2010

romain05

XLDnaute Nouveau
Bonjour à tous,

J'ai créé une macro sur Excel 2013 qui a pour but de s'exporter sur le calendrier outlook 2013.
Sur mon pc aucun problème cela fonctionne.
Cependant sur un autre ordinateur fonctionnant sous excel 2010 cela ne marche pas. De plus, sur cet ordi le fichier excel se nomme "name.pst" au lieu de "outlook.pst

Savez-vous d'où le problème peut venir ?

Je vous laisse en copie mon code:

Option Explicit

Sub Date_anniversaire()
'nécéssite d'activer la référence Microsoft Outlook 10.0 Object Library
Dim myOlApp As New Outlook.Application
Dim MyItem As Outlook.AppointmentItem
Dim Cell As Range
Dim dLgC As Long, dLgR As Long

For Each Cell In Range("A2:A" & Range("A22").End(xlUp).Row)
Set MyItem = myOlApp.CreateItem(olAppointmentItem)

With MyItem
.MeetingStatus = olNonMeeting
.Subject = Cell
.Start = Cell.Offset(0, 1)
.AllDayEvent = True
.Location = "Anniversaire"
.Save
End With

Set MyItem = Nothing
Next Cell
End Sub

Sub Date_arrivée()
'nécéssite d'activer la référence Microsoft Outlook 10.0 Object Library
Dim myOlApp As New Outlook.Application
Dim MyItem As Outlook.AppointmentItem
Dim Cell As Range
Dim dLgC As Long, dLgR As Long

For Each Cell In Range("A2:A" & Range("A22").End(xlUp).Row)
Set MyItem = myOlApp.CreateItem(olAppointmentItem)

With MyItem
.MeetingStatus = olNonMeeting
.Subject = Cell
.Start = Cell.Offset(0, 2)
.AllDayEvent = True
.Location = "arrivé"
.Save
End With

Set MyItem = Nothing
Next Cell
End Sub

Sub Date_finpériode1()
'nécéssite d'activer la référence Microsoft Outlook 10.0 Object Library
Dim myOlApp As New Outlook.Application
Dim MyItem As Outlook.AppointmentItem
Dim Cell As Range
Dim dLgC As Long, dLgR As Long

For Each Cell In Range("A2:A" & Range("A22").End(xlUp).Row)
Set MyItem = myOlApp.CreateItem(olAppointmentItem)

With MyItem
.MeetingStatus = olNonMeeting
.Subject = Cell
.Start = Cell.Offset(0, 3)
.AllDayEvent = True
.Location = "fin période 1"
.Save
End With

Set MyItem = Nothing
Next Cell

End Sub

Sub Date_finpériode2()
'nécéssite d'activer la référence Microsoft Outlook 10.0 Object Library
Dim myOlApp As New Outlook.Application
Dim MyItem As Outlook.AppointmentItem
Dim Cell As Range
Dim dLgC As Long, dLgR As Long

For Each Cell In Range("A2:A" & Range("A22").End(xlUp).Row)
Set MyItem = myOlApp.CreateItem(olAppointmentItem)

With MyItem
.MeetingStatus = olNonMeeting
.Subject = Cell
.Start = Cell.Offset(0, 4)
.AllDayEvent = True
.Location = "fin période 2"
.Save
End With

Set MyItem = Nothing
Next Cell

End Sub

Sub Echéance_mission()
'nécéssite d'activer la référence Microsoft Outlook 10.0 Object Library
Dim myOlApp As New Outlook.Application
Dim MyItem As Outlook.AppointmentItem
Dim Cell As Range
Dim dLgC As Long, dLgR As Long

For Each Cell In Range("A2:A" & Range("A22").End(xlUp).Row)
Set MyItem = myOlApp.CreateItem(olAppointmentItem)

With MyItem
.MeetingStatus = olNonMeeting
.Subject = Cell
.Start = Cell.Offset(0, 6)
.AllDayEvent = True
.Location = "échéance mission"
.Save
End With

Set MyItem = Nothing
Next Cell

With Sheets("Feuil1")
dLgC = .Range("A65536").End(xlUp).Row
If dLgC = 22 Then MsgBox "Il n'y a pas de données à transférer dans la feuille Resultats": End

Range("A2:F" & dLgC).Copy
End With

With Sheets("Feuil2")

dLgR = .Range("A65536").End(xlUp).Row + 1

.Range("A" & dLgR).PasteSpecial Paste:=xlPasteValues
End With
Sheets("Feuil1").Range("A2:F50").ClearContents
Sheets("Feuil2").Select

Call Date_anniversaire
Call Date_arrivée
Call Date_finpériode1
Call Date_finpériode2

End Sub


Merci d'avance
 

ROGER2327

XLDnaute Barbatruc
Re : Macro Excel 2013 qui ne fonctionne pas sous Excel 2010

Bonjour romain05.


Je n'ai pas vraiment de réponse, mais je peux vous dire que je n'ai pas Microsoft Outlook 10.0 Object Library dans Excel2010.
Capture13.JPG


Bonne soirée.


ℝOGER2327
#7344


Lundi 23 Palotin 141 (Saints Quatrezoneilles, Herdanpo, Mousched-Gogh, Palotins - fête Suprême Quarte)
23 Floréal An CCXXII, 8,4435h - bourrache
2014-W20-1T20:15:52Z
 

romain05

XLDnaute Nouveau
Re : Macro Excel 2013 qui ne fonctionne pas sous Excel 2010

Tout d'abord, merci pour votre réponse.

Oui en effet il n'y est pas, c'est qu'il doit sûrement y avoir quelque chose à modifier dans le code mais mes compétences ne me permettent pas de savoir ce que je dois modifier. En espérant que quelqu'un ici puisse nous éclairer :)

Bonne soirée :)
 

systmd

XLDnaute Occasionnel
Re : Macro Excel 2013 qui ne fonctionne pas sous Excel 2010

Bonsoir,

c'est bien un problème de référence apparemment en fonction de la version d'Excel

je suis sous 2007 mais essaye ceci:

Code:
Sub AjoutReferenceOutlook()
Dim xRef As String
xRef = "C:\Program Files\Microsoft Office\Office" & Val(Application.Version) & "\MSOUTL.OLB"
ThisWorkbook.VBProject.References.AddFromFile (xRef)
End Sub

il faut bien sûr que "Accès approuvé au modèle d'objet du projet VBA" soit coché dans les options
 

Discussions similaires

Réponses
1
Affichages
164
Réponses
0
Affichages
148

Statistiques des forums

Discussions
312 198
Messages
2 086 153
Membres
103 135
dernier inscrit
Imagine