Vba 对象“\u工作表”的方法“ExportAsFixedFormat”失败
以下是我将所有excel表格导出为PDF的代码:Vba 对象“\u工作表”的方法“ExportAsFixedFormat”失败,vba,excel,Vba,Excel,以下是我将所有excel表格导出为PDF的代码: Sub printing() Dim i As Integer, wkb As String, head As String, nm As String Dim ws As Worksheet Application.ScreenUpdating = False 'get folder path wkb = InputBox("Enter folder path:", , ActiveWorkbook.Path) If Right(wkb,
Sub printing()
Dim i As Integer, wkb As String, head As String, nm As String
Dim ws As Worksheet
Application.ScreenUpdating = False
'get folder path
wkb = InputBox("Enter folder path:", , ActiveWorkbook.Path)
If Right(wkb, 1) <> Application.PathSeparator Then wkb = wkb & Application.PathSeparator
'head of file name
head = InputBox("Enter head of file name", , "Test")
Application.DisplayAlerts = False
For Each ws In ActiveWorkbook.Worksheets
'ActiveWorkbook.Sheets.Count
If ws.Visible = True Then
ws.Select
nm = ws.Range("A1")
If nm <> "" Then
'save
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=wkb & head & nm & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End If
Application.DisplayAlerts = False
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
我在我的Mac和我朋友的Mac上运行此宏,但我的Mac为pass,我朋友的Mac为not pass,并出现错误:
运行时错误“1004”:
对象“\u工作表”的方法“ExportAsFixedFormat”失败
你能告诉我一个解决办法吗
谢谢。您检查过这两台机器上的所有引用都相同吗?此方法是从Excel 2007中添加的-您的朋友在Mac上使用的Excel版本是否比您的更早?@MacroMan:两台机器的操作系统版本相同,相同的Office版本您检查过两台计算机上的所有引用是否相同吗?此方法是从Excel 2007中添加的-您的朋友在Mac上使用的Excel版本是否比您更早?@MacroMan:两台计算机的操作系统版本相同,Office版本相同