I am trying to save all the worksheets as individual workbook in PDF format in a special folder with cell value. But it is giving me syntax error in below code. Can anyone help me to resolve this issue please.
Showing Error
.SaveAs FolderName _
& "\Invitation Letter - " & .Sheets(1).Range("E4").Value & FileExtStr, ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, _
Quality:=xlQualityMinimum, IncludeDocProperties:=True, IgnorePrintAreas:=False,OpenAfterPublish:=False
Original Complete Code
'Working in 97-2007
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim sh As Worksheet
Dim DateString As String
Dim FolderName As String
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
'Copy every sheet from the workbook with this macro
Set Sourcewb = ThisWorkbook
'Create new folder to save the new files in
DateString = Format(Now, "yyyy-mm-dd hh-mm-ss")
FolderName = Sourcewb.Path & "\" & Sourcewb.Name & " (Invitation Letter) " & " " & " " & DateString
MkDir FolderName
'Copy every visible sheet to a new workbook
For Each sh In Sourcewb.Worksheets
'If the sheet is visible then copy it to a new workbook
If sh.Visible = -1 Then
sh.Copy
'Set Destwb to the new workbook
Set Destwb = ActiveWorkbook
'Determine the Excel version and file extension/format
With Destwb
End With
'Change all cells in the worksheet to values if you want
If Destwb.Sheets(1).ProtectContents = False Then
With Destwb.Sheets(1).UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
End If
With Destwb
.SaveAs FolderName _
& "\Invitation Letter - " & .Sheets(1).Range("E4").Value & FileExtStr, ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, _
Quality:=xlQualityMinimum, IncludeDocProperties:=True, IgnorePrintAreas:=False,OpenAfterPublish:=False
'.SaveAs FolderName _
'& "\Invitation Letter - " & .Sheets(1).Range("E4").Value & FileExtStr, _
'FileFormat:=51 'FileFormatNum
.Close False
End With
End If
GoToNextSheet:
Next sh
Response = MsgBox("You can find the files in..." & FolderName + vbCrLf + " " + vbCrLf + "Abdul Aleem - Lets Make Life Easier...", vbOKOnly + vbInformation, "Managed Care Department")
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
Bookmarks