首页 > 解决方案 > Excel Mac 宏

问题描述

新手只是想让 Excel (Mac) 将工作表另存为 PDF,这也将文件名另存为单元格名称。我已经让它在我的 Windows Excel 中工作,但在 Mac 中出现运行时错误。请帮忙。

Sub CommandButton1_Click()
    pdfName = ActiveSheet.Range("G5") 'PDF name
    ChDir ActiveWorkbook.Path & ":" 'Use the files directory
    FileSaveName = ActiveSheet.Range("G5") 'Name the PDF file

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    FileSaveName, Quality:=xlQualityStandard, IncludeDocProperties:=True, OpenAfterPublish:=False

    MsgBox "File Saved as " & " " & FileSaveName
End Sub

标签: excelvbamacosruntime

解决方案


推荐阅读