我有一个色带上的按钮,将保存为pdf。但它会将所有可见的图纸保存为pdf。我只想让它保存活动工作表。
private void button1_Click(object sender, RibbonControlEventArgs e)
{
xl.Application xlApp = Globals.ThisWorkbook.Application;
ThisWorkbook wb = Globals.ThisWorkbook;
SaveFileDialog MyFiles = new SaveFileDialog();
MyFiles.Filter = "PDF Files|*.pdf";
MyFiles.Title = "Save As...";
MyFiles.DefaultExt = "*.pdf";
MyFiles.ShowDialog();
string path = MyFiles.FileName;
wb.ExportAsFixedFormat(xl.XlFixedFormatType.xlTypePDF, path);
}发布于 2015-04-28 21:33:57
您可能需要使用wb.ActiveSheet.ExportAsFixedFormat。这与如何在普通VBA中执行此操作是一致的。
https://stackoverflow.com/questions/29901793
复制相似问题