Auto open KML file in Google Earth

  • Hi All,

    So I have my Excel file (Creating KML file from Excel) successfully producing a KML file complete with waypoints and linestrings.

    In Hidden A1 is "C:\Program Files\Google\Google Earth Pro\client\googleearth.exe"
    In Hidden A2 is "C:\Windows\Temp\Quote.kml

    When I run the Macro the Msg Box opens with File successfully exported, Open in Google Earth?
    When I click Yes I am prompted to save the file before Google Earth opens.

    Is there a way to modify the code to auto open (overwrite?) the file referenced in Hidden A2 value without needing to save as each time?

    EDIT: to add;

    When choosing a new path for the filename, Hidden A2 gets overwritten with the new path. I thought the idea was to nominate a path in Hidden A2.

  • Hello, A2 is the kml file and path . A1 is google earth path to exe file
    untested but try,,,

    should be one of two places eg,,

    If Not Dir("C:\Program Files\Google\Google Earth Pro\googleearth.exe", vbDirectory) = vbNullString Then
            Shell "C:\Program Files\Google\Google Earth Pro\googleearth.exe" & " " & Chr(34) & FilePath & Chr(34), vbMaximizedFocus
        ElseIf Not Dir("C:\Program Files (x86)\Google\Google Earth Pro\googleearth.exe", vbDirectory) = vbNullString Then
            Shell "C:\Program Files (x86)\Google\Google Earth Pro\googleearth.exe" & " " & Chr(34) & FilePath & Chr(34), vbMaximizedFocus
            MsgBox "Google Earth does not exist"
        End If
  • Many Thanks Pike,

    It looks great, I can see what the code is saying here. Maybe one day I will be able to write it too.

    Will give it a try tomorrow, today was one-of-those-days.

    Regards, Paul

  • Pike,
    Still not quite there.
    I still have to Save as
    Thanks for you patience.

  • the double open is still in the code use

  • Closer, I changed this by adding

    GE_exe_Loc = Sheets("Hidden").Range("A1").Value


    sFilename = Sheets("Hidden").Range("A2").Value

    Bit still Explorer opens for a file selection when I click on the macro button,

  • Sheet "Hidden" A1 = C:\Program Files\Google\Google Earth Pro\client\googleearth.exe
    Sheet "Hidden" A2 = C:\Users\Paul\Desktop\quote.kml

    Though this will probably become Sheet "Hidden" A2 = C:\Windows\Temp on rollout

  • Only one Macro.
    Entire content

    When I click on the macro button Explorer Save As opens to C:\Users\Paul\Desktop with an Excel icon and Save *.kml in the top of the window.
    When I save the file in a different name "Hidden" A2 gets overwritten with the new name. After saving MsgBox opens with "File successfully exported, Open in Google Earth?"

    [ATTACH=JSON]{"data-align":"none","data-size":"full","title":"Save .kml.png","data-attachmentid":1224525}[/ATTACH]

  • Hello,
    with out the workbook and some data, try this
    what was yA??

  • I don't have GE at home but this will be correct if not very close

    when you close GE it always ask if you want to save

  • yA is the Latitude and Longitude data.

    Both sets of code still open an Explorer dialogue box to save the file. Not the usual Save As as seen normally, but a Save *.kml

    After saving and opening the file in Google Earth the filename used in the dialogue box gets overwritten to sheet "Hidden" A2.
    Here I saved as different file name and the A2 cell is now this.

    I did post a Dropbox link to the workbook previously.…%20enquiry%20v4.xltm?dl=0

    [ATTACH=JSON]{"alt":"Click image for larger version Name:\tSave .kml.png Views:\t0 Size:\t37.9 KB ID:\t1224577","data-align":"none","data-attachmentid":"1224577","data-size":"full","title":"Save .kml.png"}[/ATTACH][ATTACH=JSON]{"alt":"Click image for larger version Name:\tdifferent.png Views:\t0 Size:\t37.1 KB ID:\t1224578","data-align":"none","data-attachmentid":"1224578","data-size":"full","title":"different.png"}[/ATTACH]

  • Hi,
    There are a few thing that can be reworked
    Added loops for the klm file and logic for find google earth

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!