shahdelsol
Active Member
- Joined
- Jul 21, 2009
- Messages
- 276
- Office Version
- 365
- Platform
- Windows
I am using this code on windows and working without any problme but when I use it on Mac. The code stops with error at this line:
.SaveAs FileName:=FPath & "\" & FName, FileFormat:=51
Can anyone help please
.SaveAs FileName:=FPath & "\" & FName, FileFormat:=51
Can anyone help please
VBA Code:
Sub SaveContactXcel()
Dim FName As String
Dim FPath As String
FPath = "/Users/abc/Desktop/books/"
FName = Sheets("sheet1").Range("J1").Text & " " & Sheets("sheet1").Range("C10").Text
If (Len(Range("C10")) < 3) Then
MsgBox "You must have at least first name in cell C10 before saving"
Exit Sub
Else
Application.DisplayAlerts = False
'copy all sheets into new workbook
ActiveWorkbook.Sheets.Copy
Set wb = ActiveWorkbook
ActiveWorkbook.Sheets.Copy
Set wb = ActiveWorkbook
With wb
On Error Resume Next
.Sheets("Sheet1").Shapes("Save").Delete
.Sheets("Sheet1").Range("J2:K2").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
On Error GoTo 0
.SaveAs FileName:=FPath & "\" & FName, FileFormat:=51
.Close SaveChanges:=True
End With
Application.DisplayAlerts = True
Application.Quit
MsgBox "The Contract Has Been Saved Successfully!"
Set wb = Nothing
End If
End Sub