Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Does anyone know how to convert a kml file to a kmz file programmatically in vba excel.

I am able to convert kml files to kmz mannually by opening a kml file in Google earth and going to File->Save->Save place as, like this i am converting it to kmz files.

But i want to convert programmatically in vba as, if we give input to macro as kml it should have to convert into kmz file .

I had explored this i found some conversion tools like kmlkmz converter which will does this process automatically but i am supposed to do this in vba .So please suggest if any one know this.
Posted

1 solution

It is quite easy when you read about the structure of KMZ here: KMZ Files[^]. You won't be needing any supporting files if your original KML file does not reference external files:

Here an excerpt from the site above I linked to:


  1. Create a folder that will contain the contents of your KMZ file. Give it a descriptive name (for example, buffetthawaiitour).
  2. Put the default KML file (doc.kml, or whatever name you want to give it) at the top level within this folder. Include only one .kml file. (When Google Earth opens a KMZ file, it scans the file, looking for the first .kml file in this list. It ignores all subsequent .kml files, if any, in the archive. If the archive contains multiple .kml files, you cannot be sure which one will be found first, so you need to include only one.)
  3. Include one or more subfolders within the main folder to collect images, models, textures, sound files, or other resources referenced in the doc.kml file. The complexity of this directory structure depends on the number of supporting files and your preferences for organization.
  4. Use relative references. See References to External Files for more details. All relative paths begin inside the base folder described above in item 1. For example, if a KMZ file vacationJournal.kmz is on the desktop, and its doc.kml file refers to a file myFavoritePlace.jpg, which is also on the desktop, the href in the doc.kml file is ../myFavoritePlace.jpg.
  5. Do not use the .kmz extension for any of the subfolders within a KMZ file. The .kmz extension is reserved for the name of the archive itself.


Regards,

Manfred
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900