Search code examples
macosvbaexcelexcel-2011

OS X Excel 2011 VBA Save File Name


I need to write a script to save a worksheet with to a predetermined location and the save name is filled from values within the worksheet. I can get it to save in the proper location, but the file name returns a combination of FATPMetiFolderPath and FATPMetiPath (\Volumes\MFS1\Groups\METI...\METIman\MMP0123 - FATP.xlsm). I can do this just fine with Windows Excel VBA, but I have never used a Mac before. I am programming on a PC, but it needs to be able to be saved properly if used on a Mac.

Sub saveFATPMMMac()

 'Saves copy for access for everyone
 Dim FATPMetiPath As String
 Dim FATPMetiFolderPath As String


 FATPMetiFolderPath = "\Volumes\MFS1\Groups\METI\Quality Control\Function and Acceptance Test Documents\METIman\"
 'FATPMetiFolderPath = "C:\Users\gzapantis\Desktop\"
 FATPMetiPath = FATPMetiFolderPath & _
    Sheets("Failure Report").Range("FailReportSN").Text & " - FATP " & ".xlsm"

 ThisWorkbook.SaveAs Filename:=FATPMetiPath

End Sub

Solution

  • I have solved the problem. It saves it with the correct file name and in the correct location.

    Sub saveFATPMMMac()
    'Saves copy for access for everyone
      Dim FATPMetiPath As String
      Dim FATPMetiFolderPath As String
    
     If Application.PathSeparator = ":" Then
        FATPMetiFolderPath = "Volumes:MFS1:Groups:METI:Quality Control:Function and Acceptance Test Documents:METIman:"
     Else
        FATPMetiFolderPath = "F:\Groups\METI\Quality Control\Function and Acceptance Test Documents\METIman\"
     End If
    
     FATPMetiPath = FATPMetiFolderPath & _
        Sheets("Failure Report").Range("FailReportSN").Text & " - FATP.xlsm"
    
     ThisWorkbook.SaveAs Filename:=FATPMetiPath
    
    End Sub
    

    Thank you for pointing me in the right direction.