http://www.access-programmers.co.uk/forums/showthread.php?t=195044
Dim MyDB As Database
Dim MyRS As Recordset
Dim fld As Field
Dim strText As String
Dim MyTableName As String
Dim QryOrTblDef As String
Dim iFile As Integer
QryOrTblDef = "DanielsKMLtest" 'this is a query
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(QryOrTblDef)
iFile = FreeFile
'creates the blank file with the follwing name
Open "c:\KMLTest.kml" For Output Shared As #iFile
'writes to the file using input from the query
Print #iFile, ""
Print #iFile, "
Print #iFile, "
Print #iFile, "
'creates a folder in google earth architechure
Print #iFile, "
Print #iFile, "
Print #iFile, "
'creates another folder (sub to the above folder
Print #iFile, "
Print #iFile, "
Print #iFile, "
Print #iFile, "
With MyRS
Do Until .EOF
Print #iFile, "
strText = "
City: " & MyRS.Fields(1) & "
Phone: " & MyRS.Fields(3) & "]]>
Print #iFile, strText
strText = "
Print #iFile, strText
'Print #iFile, "
'imports the lat and long from the 5th field (first field is a 0) in the query
strText = " " & MyRS.Fields(4) & " "
Print #iFile, strText
'Print #iFile, "
" Print #iFile, "
" .MoveNext
Loop
End With
Print #iFile, "
" Print #iFile, "
" Print #iFile, "
" Print #iFile, "
" Close #iFile
MyRS.Close
'resest the recordset and database to blank
Set MyRS = Nothing
Set MyDB = Nothing
'launches google earth
Call Shell("explorer.exe " & "c:\KMLTest.kml", vbNormalFocus)
End Sub
Nessun commento:
Posta un commento