最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

excel - Mac VBA for pdf is sending file to print rather than creating and saving in folder - Stack Overflow

programmeradmin4浏览0评论

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```
发布评论

评论列表(0)

  1. 暂无评论