Voici le script qui vous permettra de synchroniser les clients à partir du logiciel EBP en base Access vers PlanningPME.
'Connection to PlanningPME
'Register PlanningPME.dll before -> c:\windows\system32\regsvr32 PlanningPME.dll
Set ppme = CreateObject("PlanningPME.Application")
ppme.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=P:\Documentation\Intégrations\Access\EBP - CLients\PPME.pp"
ppme.Connect
'Connection to Base Access
Set Connection = CreateObject("ADODB.Connection")
'VB
Connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=P:\Documentation\Intégrations\Access\EBP - CLients\Societededemonstration0500.mdb"
Set rs = CreateObject("ADODB.Recordset")
Set search = CreateObject("ADODB.Recordset")
rs.Open "select clID, clNom, clAdr1, clCP, clVille, clPays, clTel, clMob, clFax, clMail, clWeb, clNomBnq, clCpteBqe, clNII, clIBAN from [Client]", Connection
'Parse Access file and create customer if not exist
While rs.EOF = False
Set c = ppme.CreateItem(4) 'PpDoCustumer
' CUSTOMER_ID non vide
If IsNull(rs.Fields("clID")) = False Then
c.Number = rs.Fields("clID")
' search the custumer in planningpme
search.Open "select IDX_CLIENT from CLIENT where NUMERO_CLIENT='" & c.Number & "'", ppme.Connection
' if exist load the object
If search.EOF = False Then
c.Key = search.Fields("IDX_CLIENT")
c.Load2
End If
'Create Custumer with PlanningPME object
If IsNull(rs.Fields("clNom")) = False Then
c.Company = rs.Fields("clNom")
End If
If IsNull(rs.Fields("clAdr1")) = False Then
c.Adress = rs.Fields("clAdr1")
End If
If IsNull(rs.Fields("clCP")) = False Then
c.ZIP = rs.Fields("clCP")
End If
If IsNull(rs.Fields("clVille")) = False Then
c.City = rs.Fields("clVille")
End If
If IsNull(rs.Fields("clPays")) = False Then
c.Country = rs.Fields("clPays")
End If
If IsNull(rs.Fields("clMail")) = False Then
c.Email = rs.Fields("clMail")
End If
If IsNull(rs.Fields("clTel")) = False Then
c.Phone = rs.Fields("clTel")
End If
If IsNull(rs.Fields("clMob")) = False Then
c.Mobile = rs.Fields("clMob")
End If
If IsNull(rs.Fields("clFax")) = False Then
c.Fax = rs.Fields("clFax")
End If
If c.Fields.Count > 3 Then
If IsNull(rs.Fields("clCpteBqe")) = False Then
c.Fields.Item(0).Value = rs.Fields("clCpteBqe")
End if
If IsNull(rs.Fields("clNomBnq")) = False Then
c.Fields.Item(1).Value = rs.Fields("clNomBnq")
End if
If IsNull(rs.Fields("clNII")) = False Then
c.Fields.Item(2).Value = rs.Fields("clNII")
End if
If IsNull(rs.Fields("clIBAN")) = False Then
c.Fields.Item(3).Value = rs.Fields("clIBAN")
End if
End if
c.Save
search.Close
End If
rs.MoveNext
Wend
Lectures recommandées sur ce thème :