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:
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
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 am just trying to figure out the syntax for adding this sort of error handler. Any help would be GREATLY appreciated!
Thanks