VBA Error Handler for Mac saving file

MJH2014

New Member
Joined
Apr 24, 2014
Messages
9
Hi all,

I wrote a macro for our accounting department that generates a PO number for purchase orders by referencing numbers that have already been used, copies the tab to a new workbook, deletes the macro buttons off of it, and saves the purchase order in a specified location on the network drive.

However, it came to my attention it is not working for mac users and I think it is because the file path to the target folder for saving it is different for mac users. My code (for the file save portion) is below:

Code:
MyFileName = "PO Number" & "_" & ws1.Range("H3").Value


If Not Right(MyFileName, 5) = ".xlsx" Then MyFileName = MyFileName & ".xlsx"


'Kick out a saved non-macro file to designated file location; Reformat to hardcode date on PO and remove buttons
Sheets("PO").Copy
ActiveSheet.Shapes.Range(Array("Button 1")).Delete
ActiveSheet.Shapes.Range(Array("Button 2")).Delete
Range("H2").Copy
Range("H2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False


    MyPath = "L:\PO\Purchase Orders" & "\"
    
With ActiveWorkbook
    .SaveAs Filename:=MyPath & MyFileName, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    .Close False
End With


'Add entry to reference tab to not be used again
ws1.Range("H3").Copy
ws2.Range("A" & POCount + 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        Application.CutCopyMode = False


ws1.Activate
Application.ScreenUpdating = True


End Sub
I know that I need to create an error handler that on an error will then try to save under a different file path, (I am thinking resaving with a different "MyPath" set to: MacPath = "\\10.1.1.104\DeptDirectories\PO\Purchase Orders" & "\")

I am just trying to figure out the syntax for adding this sort of error handler. Any help would be GREATLY appreciated!

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,215,219
Messages
6,123,687
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top