0

I have an Excel VBA code that used to work fine. After a recent Excel update, the code generates Run-time error '75':Path/File access error.

The code is supposed to open a file for output in the same location where the XLSX file is run from, in this case my DropBox.

Sub OpenKMLFile()
    Dim OutputPath As String
        
    OutputPath = ThisWorkbook.Path
    
    If InStr(1, OutputPath, "\") >= 1 Then
        'Output File Path for Windows
        OutputPath = OutputPath & "\" & KMLFileName & ".kml"
    ElseIf InStr(1, OutputPath, "/") >= 1 Then
        'Ouotput Path for Mac with '/'
        OutputPath = OutputPath & "/" & KMLFileName & ".kml"
    Else
        'Ouotput Path for Mac with ':'
        OutputPath = OutputPath & ":" & KMLFileName & ".kml"
    End If
    
    KMLFileNumber = FreeFile()
    Open OutputPath For Output As KMLFileNumber
End Sub

enter image description here

enter image description here

braX
  • 11,506
  • 5
  • 20
  • 33
Guy Fisher
  • 31
  • 4

1 Answers1

0

Found solution. Because it's a cloud based location mirroring the DropBox cloud drive, it seems it can't access this unless a file already exists there, otherwise I'm guessing that location "doesn't exist" even though there are a bunch of other files in the same folder including the XLSX file that's running this script.

So I created an empty text file in that location:

/Users/guyfisher/Library/CloudStorage/Dropbox/GPS/Earth Text/CGS2.kml

Then ran the VBA script, and it worked, Mac OS requested permission to access the file and then the script was able to write the KML data into that file.

Guy Fisher
  • 31
  • 4