【问题标题】:VBA macro working on Excel 2016 for Windows but not for macVBA 宏适用于 Windows 的 Excel 2016,但不适用于 Mac
【发布时间】:2016-04-08 07:49:53
【问题描述】:

我在 Excel 2016 上有一个宏,它非常适合创建 PDF。 但此宏仅适用于 Excel 2016 for Windows。 我在 Mac 的 Excel 2016(最新版本)上尝试了它,但它不起作用。

这是我的宏

Sub Macro1()

Dim Chemin As String
Dim texte As String

Chemin = ThisWorkbook.Path & "/"
texte = Range("C3")
Application.DisplayAlerts = False

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=Chemin & texte & ".pdf", _
Quality:=xlQualityMinimum, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Cells(1, 3).Value = Cells(1, 3).Value + 1

End Sub

我进行了大量搜索,似乎“ExportAsFixedFormat Type:=xlTypePDF”在 Mac 的最新 Excel 版本上不起作用。 但我找不到其他方法。

【问题讨论】:

标签: excel vba macos


【解决方案1】:

我遇到了同样的问题。

我在 Excel 2016 中用英语编写了代码(在安装了 Windows 的 HP 计算机上),然后我尝试在安装了法语的 Mac 上执行相同的 Excel 文件。我注意到问题在于语言。

例如问题代码:

Private Sub 
  Cancelbutton_Click()... 
End Sub

为了执行它需要:

Private Sub 
  Cancelbutton_Cliquer(...
End Sub

【讨论】:

    【解决方案2】:

    如果你想通过Excel在MAC上创建文件夹或创建文件,你需要使用Scripting.FileSystemObject

    Set fs = CreateObject("Scripting.FileSystemObject")
    

    【讨论】:

      猜你喜欢
      • 2017-01-01
      • 1970-01-01
      • 2021-10-27
      • 2012-02-08
      • 1970-01-01
      • 1970-01-01
      • 2016-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多