导出为PDF仅打开第二张图表 [英] Exporting As PDF opens only second chart
问题描述
尝试将报告"工作表导出为PDF并打开它.问题在于开放的只是该工作表底部的第二张图表.
Trying to export my "Report" worksheet as a PDF and open it. Issue is that all that's opening up is the second chart at the bottom of that worksheet.
我的代码:
ThisWorkbook.Sheets("Report").Activate
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=ActiveWorkbook.Path & "\Report.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
应该在PDF中显示什么:
What's supposed to be showing in the PDF:
PDF中实际显示的内容:
What's actually showing up in the PDF:
推荐答案
这是Excel的一个众所周知的问题:为此,ActiveSheet
也可以是一个图表...
如果您有一个活动图表,则将导出该图表.
It is a well known problem of Excel: For it ActiveSheet
can be a Chart, too...
If you have an active chart, this one will be exported.
因此,将其放置在导出行之前就足够了:
So, it is enough to place before the exporting line :
ActiveSheet.Range("A1").Select
或者确保未选择图表甚至更好的图表,请尝试将表格的资格设置为:
Or be sure that a chart is not selected and even better, try qualifying your sheet as:
Dim sh As Worksheet
Set sh = Worksheets("sheet_name")
这篇关于导出为PDF仅打开第二张图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!