I have the below code which is working in principle but seems to be sending the file to my printer and not creating a folder and saving the pdf there.
Have a sheet that needs to be pdfed and saved in a folder. The same sheet is then blanked and used for another entry, so the pdf becomes the record of the information entered and for mailing on to suppliers etc.
Help, please!
Dim FolderName As String
Dim FolderString As String
Dim FilePathName As String
ActiveSheet.PageSetup.Orientation = ActiveSheet.PageSetup.Orientation
FolderName = "PDFFolder"
FileName = ActiveSheet.Name & ".pdf"
FolderString = "C:"
FilePathName = FolderString & Application.PathSeparator & FileName
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
FilePathName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False
MsgBox "Success - Your PO can be found here :" & FilePathName
End Sub
Function CreateFolder(NameFolder As String) As String
Dim OfficeFolder As String
Dim PathToFolder As String
Dim TestStr As String
OfficeFolder = MacScript("retrun POSIX path of (path todesktop folder) as string")
OfficeFolder = Raplace(OfficeFolder, "/Desktop", "") & _
"Library/Group Containters/UBF8T346G9.Office/"
PathToFolder = OfficeFolder & NameFolder
On Error Resume Next
TestStr = Dir(PathToFolder & "*", vbDirectory)
On Error GoTo 0
If TestStr = vbNullString Then
MkDir PathToFolder
MsgBox "You find the new folder in this location :" & PathToFolder
End If
CreateFolder = PathToFolder
End Function```