Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 将使用ExportAsFixedFormat发送到打印机,而不是Excel 2016_Macos_Vba_Excel_Excel 2016 - Fatal编程技术网

Macos 将使用ExportAsFixedFormat发送到打印机,而不是Excel 2016

Macos 将使用ExportAsFixedFormat发送到打印机,而不是Excel 2016,macos,vba,excel,excel-2016,Macos,Vba,Excel,Excel 2016,我正在尝试制作一个只将特定区域导出为PDF格式的宏。我的工作簿中有多张工作表,但我不能将SaveAs与xlSelection一起使用,因为该参数存在错误,它会将整个工作簿导出为PDF格式。以下是我的代码: Sub Export() ' ' Export Macro ' ' Keyboard Shortcut: Option+Cmd+p ' Range("B1:G32").Select Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename

我正在尝试制作一个只将特定区域导出为PDF格式的宏。我的工作簿中有多张工作表,但我不能将SaveAs与xlSelection一起使用,因为该参数存在错误,它会将整个工作簿导出为PDF格式。以下是我的代码:

Sub Export()
'
' Export Macro
'
' Keyboard Shortcut: Option+Cmd+p
'
Range("B1:G32").Select

Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:="~:Desktop:Quote.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True

End Sub

请告诉我是否有我可以尝试的解决方案。

以下是我的代码,它成功地将我的资料保存到pdf。我正在保存整个工作表,而不是某些单元格。也许你可以修改我的代码来做你想做的。另一件事是我的代码是用VB.net在Visual Studio中编写的,所以请对vba进行适当的转换

如果保存单元格对您不起作用,您可以复制所需的所有单元格,将它们粘贴到新工作表中,然后将整个新工作表保存到pdf。这是可以通过vba实现的

 xlWorkSheet.ExportAsFixedFormat(Type:=Excel.XlFixedFormatType.xlTypePDF,
                                    Filename:=output_dir & "\" & test_set & "_" & sub_test & ".pdf",
                                    IgnorePrintAreas:=True,
                                    OpenAfterPublish:=False,
                                    Quality:=Excel.XlFixedFormatQuality.xlQualityStandard)