The code below will automate google earth and open the KML file located in the path “D:StuffBusinessTemp”, under the name “Untitled Placemark.kml”:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub main() Dim appGoogleEarth As EARTHLib.ApplicationGE Set appGoogleEarth = New EARTHLib.ApplicationGE Sleep 5000 Call appGoogleEarth.OpenKmlFile( _ "D:StuffBusinessTempUntitled Placemark.kml", 1) End Sub
Note: The first line of code allows us to use the Sleep function. The reason for using the sleep function, is to allow Google Earth to load. If Google Earth has not finished loading and we attempt to open the KML file an error will occur.
You can download the file and code used in this article from the link below: