Bonjour,
Je récupère des données d'un recordSet pour en faire un tableaux de données au format JavaScript que j'ajoute à un fichier html. Mais problème, avec les caractères spéciaux sont mal interprétés dans l'html.
Côté Access
Avec pour résultat dans le fichier html
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 Private Sub cmdGeoloc2_Click() Dim sPath, strHtml, markers, sSQL As String Dim i As Integer Dim TextString As Variant Dim marker As clsMarker sSQL = "SELECT ...." Call ecrireFichier(sSQL) Set rdSet = CurrentDb.OpenRecordset(sSQL) rowNbr = rdSet.RecordCount Do While Not rdSet.EOF = True marker.lat = rdSet![LatUs] marker.lng = rdSet![LongUS] marker.titre = rdSet![name] marker.info = rdSet![chain name] marker.type = "H" If Not (IsNull(marker.lat) Or IsNull(marker.lng)) Then With marker markers = markers & "{'lat': " & .lat & "," markers = markers & "'lng' : " & .lng & "," markers = markers & "'titre': '" & .titre & "'," 'markers = markers & """info"" :'true'," & vbCrLf markers = markers & "'info': '" & .info & "'," markers = markers & "'type' :'" & .type & "'}," End With End If rdSet.MoveNext Loop rdSet.Close If rowNbr > 0 Then strHtml = "var arrMarkers= [" & Left(markers, Len(markers) - 1) & "];" End If ' Open read handle. sPath = "E:\GeoCoding\geoloc2.html" 'read text from file TextString = Split(CreateObject("Scripting.FileSystemObject").OpenTextFile(sPath).ReadAll, Chr(13) & Chr(10)) 'change your text here as TextString(#Line - 1) = "Text still assume you want to replace line 5 TextString(16) = strHtml 'write back in file CreateObject("Scripting.FileSystemObject").CreateTextFile(sPath).Write (Join(TextString, Chr(13) & Chr(10))) End Sub
var arrMarkers= [{'lat': 47.2152,'lng' : -1.54694,'titre': Centre Cit�','info': 'info1','type' :'H'},
{'lat': 47.207,'lng' : -1.54846,'titre': 'Centre Bord de Loire','info': 'info2','type' :'H'}];
Merci par avance pour votre aide
Partager