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.
Sub ExportKML() sFilename = Application.GetSaveAsFilename(Quote & ".kml", _ "Google Earth files (*.kml),*.kml", 1, "Save *.kml") If sFilename = False Then Exit Sub Else Sheets("Hidden").Range("A2") = sFilename End If Set filepath = Sheets("Hidden").Range("A2") ' Set document name docName = "Charter Quote" Open filepath For Output As #1
openinGE = MsgBox("File successfully exported, Open in Google Earth?", vbYesNo + vbInformation, "Open") If openinGE = vbYes Then GE_exe_Loc = [Hidden!A1] If GE_exe_Loc = "" Then GE_exe = MsgBox("Could not locate Google Earth executable, Locate manually?", vbOKCancel + vbCritical, "Google Earth exe") If GE_exe = vbCancel Then Exit Sub Else GE_exe_Loc = Application.GetOpenFilename("googleearth (*.exe),*.exe", _ 1, "Browse for Google Earth exe", , False) If GE_exe_Loc = False Then Exit Sub Else Sheets("Hidden").Range("A1") = GE_exe_Loc End If End If End If sFilename = [Hidden!A2] Shell (CStr([GE_exe_Loc]) & " " & sFilename) Exit Sub ElseIf openinGE = vbNo Then Exit Sub