If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from a q
I have an address query which ouputs a single field to text strings for
Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a ‘.kml’ extension, for example ‘Addresses.kml’ This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml |
#2
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from a q
Search for this text in this group: "Export to File.Dat"
You will find the helpful answer I got from Ken Snell on renaming your exported text file. "efandango" wrote: I have an address query which ouputs a single field to text strings for Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a ‘.kml’ extension, for example ‘Addresses.kml’ This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml |
#3
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from a q
There are many ways of skinning this cat. I'd probably do something like
this (air code): Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "D:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="1.0" encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" '... 'Output address Set rsR = CurrentDB.Open("My Query") Print #lngFN, rsR.Fields("kml Address") Close rsR 'Output footer Print #lngFN blah blah Close #lngFN On Thu, 10 May 2007 10:35:01 -0700, efandango wrote: I have an address query which ouputs a single field to text strings for Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a ‘.kml’ extension, for example ‘Addresses.kml’ This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml -- John Nurick [Microsoft Access MVP] Please respond in the newsgroup and not by email. |
#4
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from
John,
thanks for your reply. I must confess it seems a little 'hardcore' for a novice such as me. Can you walk me through the broad points of the syntax used? "John Nurick" wrote: There are many ways of skinning this cat. I'd probably do something like this (air code): Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "D:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="1.0" encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" '... 'Output address Set rsR = CurrentDB.Open("My Query") Print #lngFN, rsR.Fields("kml Address") Close rsR 'Output footer Print #lngFN blah blah Close #lngFN On Thu, 10 May 2007 10:35:01 -0700, efandango wrote: I have an address query which ouputs a single field to text strings for Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a ‘.kml’ extension, for example ‘Addresses.kml’ This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml -- John Nurick [Microsoft Access MVP] Please respond in the newsgroup and not by email. |
#5
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from
John,
I have 'filled in' your code to thus far: Private Sub Test_Click() Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "D:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="; 1#; " encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" '... 'Output address Set rsR = CurrentDb.Open("Generate KML") Print #lngFN, rsR.Fields("KML_Address") Close rsR 'Output footer Print #lngFN blah blah Close #lngFN End Sub But I am stuck on the Header and Footer: What do I call them?; just header.txt footer.txt. do i put the full path in? D:\folder\header.txt and how do i get them to insert into the 'Addresses.kml' file? "John Nurick" wrote: There are many ways of skinning this cat. I'd probably do something like this (air code): Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "D:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="1.0" encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" '... 'Output address Set rsR = CurrentDB.Open("My Query") Print #lngFN, rsR.Fields("kml Address") Close rsR 'Output footer Print #lngFN blah blah Close #lngFN On Thu, 10 May 2007 10:35:01 -0700, efandango wrote: I have an address query which ouputs a single field to text strings for Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a ‘.kml’ extension, for example ‘Addresses.kml’ This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml -- John Nurick [Microsoft Access MVP] Please respond in the newsgroup and not by email. |
#6
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from
John,
Just ignore the previous two posts from me. This is how far i have got in adapting your code Private Sub Test_Click() Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "W:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="; 1#; " encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" Print #lngFN, "Document" Print #lngFN, "nameAddress List/name" Print #lngFN, "Folder" Print #lngFN, "nameLocations/name" Print #lngFN, "open1/open" '... 'Output address Set rsR = CurrentDb.Open("Generate_KML") Print #lngFN, rsR.Fields("KML_Address") Close rsR 'Output footer Print #lngFN, "/Folder" Print #lngFN, "/Document" Print #lngFN, "/kml" '... Close #lngFN End Sub But i get an error message: 'Method or Data Member not found' on the word 'Open' in the following line: Set rsR = CurrentDb.Open("Generate_KML") It suggests that something is mispelled or wrong reference, so I was worried that the query it was calling was two seperate words, so I changed it to one whole_word. But it still reports the same error message. Can you help me with this? "John Nurick" wrote: There are many ways of skinning this cat. I'd probably do something like this (air code): Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "D:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="1.0" encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" '... 'Output address Set rsR = CurrentDB.Open("My Query") Print #lngFN, rsR.Fields("kml Address") Close rsR 'Output footer Print #lngFN blah blah Close #lngFN On Thu, 10 May 2007 10:35:01 -0700, efandango wrote: I have an address query which ouputs a single field to text strings for Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a ‘.kml’ extension, for example ‘Addresses.kml’ This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml -- John Nurick [Microsoft Access MVP] Please respond in the newsgroup and not by email. |
#7
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from
My fault - though I warned you it was air code. Should be
CurrentDB.OpenRecordset("Generate_KML", dbOpenSnapshot) not CurrentDB.Open("Generate_KML") On Thu, 10 May 2007 16:41:00 -0700, efandango wrote: John, Just ignore the previous two posts from me. This is how far i have got in adapting your code Private Sub Test_Click() Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "W:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="; 1#; " encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" Print #lngFN, "Document" Print #lngFN, "nameAddress List/name" Print #lngFN, "Folder" Print #lngFN, "nameLocations/name" Print #lngFN, "open1/open" '... 'Output address Set rsR = CurrentDb.Open("Generate_KML") Print #lngFN, rsR.Fields("KML_Address") Close rsR 'Output footer Print #lngFN, "/Folder" Print #lngFN, "/Document" Print #lngFN, "/kml" '... Close #lngFN End Sub But i get an error message: 'Method or Data Member not found' on the word 'Open' in the following line: Set rsR = CurrentDb.Open("Generate_KML") It suggests that something is mispelled or wrong reference, so I was worried that the query it was calling was two seperate words, so I changed it to one whole_word. But it still reports the same error message. Can you help me with this? "John Nurick" wrote: There are many ways of skinning this cat. I'd probably do something like this (air code): Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "D:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="1.0" encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" '... 'Output address Set rsR = CurrentDB.Open("My Query") Print #lngFN, rsR.Fields("kml Address") Close rsR 'Output footer Print #lngFN blah blah Close #lngFN On Thu, 10 May 2007 10:35:01 -0700, efandango wrote: I have an address query which ouputs a single field to text strings for Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a ‘.kml’ extension, for example ‘Addresses.kml’ This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml -- John Nurick [Microsoft Access MVP] Please respond in the newsgroup and not by email. |
#8
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from
John,
I now get this error in the line: Close rsR: (highlighting the word 'Close') Compile error: Type mismatch: "John Nurick" wrote: My fault - though I warned you it was air code. Should be CurrentDB.OpenRecordset("Generate_KML", dbOpenSnapshot) not CurrentDB.Open("Generate_KML") On Thu, 10 May 2007 16:41:00 -0700, efandango wrote: John, Just ignore the previous two posts from me. This is how far i have got in adapting your code Private Sub Test_Click() Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "W:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="; 1#; " encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" Print #lngFN, "Document" Print #lngFN, "nameAddress List/name" Print #lngFN, "Folder" Print #lngFN, "nameLocations/name" Print #lngFN, "open1/open" '... 'Output address Set rsR = CurrentDb.Open("Generate_KML") Print #lngFN, rsR.Fields("KML_Address") Close rsR 'Output footer Print #lngFN, "/Folder" Print #lngFN, "/Document" Print #lngFN, "/kml" '... Close #lngFN End Sub But i get an error message: 'Method or Data Member not found' on the word 'Open' in the following line: Set rsR = CurrentDb.Open("Generate_KML") It suggests that something is mispelled or wrong reference, so I was worried that the query it was calling was two seperate words, so I changed it to one whole_word. But it still reports the same error message. Can you help me with this? "John Nurick" wrote: There are many ways of skinning this cat. I'd probably do something like this (air code): Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "D:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="1.0" encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" '... 'Output address Set rsR = CurrentDB.Open("My Query") Print #lngFN, rsR.Fields("kml Address") Close rsR 'Output footer Print #lngFN blah blah Close #lngFN On Thu, 10 May 2007 10:35:01 -0700, efandango wrote: I have an address query which ouputs a single field to text strings for Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a ‘.kml’ extension, for example ‘Addresses.kml’ This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml -- John Nurick [Microsoft Access MVP] Please respond in the newsgroup and not by email. |
#9
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from
That's supposed to be rsR.Close (the Close #lngFN is correct though)
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "efandango" wrote in message ... John, I now get this error in the line: Close rsR: (highlighting the word 'Close') Compile error: Type mismatch: "John Nurick" wrote: My fault - though I warned you it was air code. Should be CurrentDB.OpenRecordset("Generate_KML", dbOpenSnapshot) not CurrentDB.Open("Generate_KML") On Thu, 10 May 2007 16:41:00 -0700, efandango wrote: John, Just ignore the previous two posts from me. This is how far i have got in adapting your code Private Sub Test_Click() Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "W:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="; 1#; " encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" Print #lngFN, "Document" Print #lngFN, "nameAddress List/name" Print #lngFN, "Folder" Print #lngFN, "nameLocations/name" Print #lngFN, "open1/open" '... 'Output address Set rsR = CurrentDb.Open("Generate_KML") Print #lngFN, rsR.Fields("KML_Address") Close rsR 'Output footer Print #lngFN, "/Folder" Print #lngFN, "/Document" Print #lngFN, "/kml" '... Close #lngFN End Sub But i get an error message: 'Method or Data Member not found' on the word 'Open' in the following line: Set rsR = CurrentDb.Open("Generate_KML") It suggests that something is mispelled or wrong reference, so I was worried that the query it was calling was two seperate words, so I changed it to one whole_word. But it still reports the same error message. Can you help me with this? "John Nurick" wrote: There are many ways of skinning this cat. I'd probably do something like this (air code): Dim rsR As DAO.Recordset Dim strLine As String Dim lngFN As Long 'Create empty text file lngFN = FreeFile() Open "D:\Folder\Addresses.kml" For Output As #lngFN 'Output header 'NB: need to double quotes in literal strings Print #lngFN, "?xml version="1.0" encoding=""UTF-8""?" Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0""" '... 'Output address Set rsR = CurrentDB.Open("My Query") Print #lngFN, rsR.Fields("kml Address") Close rsR 'Output footer Print #lngFN blah blah Close #lngFN On Thu, 10 May 2007 10:35:01 -0700, efandango wrote: I have an address query which ouputs a single field to text strings for Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a '.kml' extension, for example 'Addresses.kml' This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml -- John Nurick [Microsoft Access MVP] Please respond in the newsgroup and not by email. |
#10
|
|||
|
|||
Creating a custom text export file (inc. header & footer) from a q
Douglas,
I pasted your code (with subtle changes to the 'rs' references...: Private Sub Test_Click() Dim db As DAO.Database Dim qdf As DAO.QueryDef Dim rs As DAO.Recordset Dim strRun_No As String strRun_No = InputBox("Enter the Run No") If Len(strRun_No) 0 Then Set db = CurrentDb() Set qdf = db.QueryDefs("Generate_KML") qdf.Parameters("Run_No") = [Run_No] ' or qdf![Run_No] = [Run_No] Set rs = qdf.OpenRecordset(dbOpenSnapshot) Do Until rs.EOF = True Print #lngFN, rs.Fields("KML_Address") rs.MoveNext Loop rs.Close 'Output footer Print #lngFN, "/Folder" Print #lngFN, "/Document" Print #lngFN, "/kml" '... Close #lngFN End If End Sub When I run it, the dialog box for the user Run No pops up, but then I hit OK, i get this error message: Run-time error '3265': Item not found in this collection. and the vba highlights this line in the editor: qdf.Parameters("Run_No") = [Run_No] ' or qdf![Run_No] = [Run_No] I tried that line to just say: qdf![Run_No] = [Run_No] but still the same error message. "efandango" wrote: I have an address query which ouputs a single field to text strings for Google Earth .kml file format parameters. The problem is that the .kml file requires a header and footer text to be inserted. Does anyone know how I can pre-insert the Header and Footer into a standard text file, and then save it with a ‘.kml’ extension, for example ‘Addresses.kml’ This is the Header: ?xml version="1.0" encoding="UTF-8"? kml xmlns="http://earth.google.com/kml/2.0" Document nameAddress List/name Folder nameLocations/name open1/open Output Field: [kml Address] This is the Footer: /Folder /Document /kml |
Thread Tools | |
Display Modes | |
|
|