无法在Mac中保存为VBA中的PDF [英] Unable to save as PDF from VBA in mac

查看:248
本文介绍了无法在Mac中保存为VBA中的PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过VBA从PDF中保存一个范围。以下是我写的代码。

I am trying to save a range from a sheet as PDF through VBA. Following is the code that I have written.

Sheets("PO Format").PageSetup.PrintArea = "$B$6 : $J$42"
Sheets("PO Format").Range("B6:J42").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Sheets("User Settings").Range("B15") & "/" & Sheets("PO Format").Range("F7"), Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True

奇怪的是,它在一个系统上工作正常,我可以将其保存在所提到的路径上,然后也发送邮件,但是在另一个系统上测试我收到错误为打印时出错。完全无知任何人都可以帮助?

The weird thing is that it is working fine on one system and I able to save it at the mentioned path and then also send out a mail, but while testing it on another system I am getting the error as "Error while printing". Completely clueless. Can anyone help??

推荐答案

在Mac Office 2016中,微软必须处理苹果的沙箱要求,因为哪个VBA需要访问权限文件夹,并且尝试通过VBA保存时不会提示,否则会给出错误。但是Mac上有几个地方可以使用这些代码来执行所需的操作,而无需用户交互。

In Mac Office 2016 Microsoft have to deal with Apple’s sandbox requirements due to which VBA needs permission to access folders and this is not prompted while trying to save via VBA instead it gives an error. But there are a few places on Mac that one can use to let the code do what it needs to do without user interaction.

一个这样的路径是/ Users / username /图书馆/集装箱/ UBF8T346G9.Office
安装Office 2016时,将创建此文件夹。

one such path is /Users/username/Library/Group Containers/UBF8T346G9.Office This folder gets created when Office 2016 is installed.

所以我将PDF保存到此文件夹,将其移动到期望的位置,它现在正常工作。

So I saved the PDF to this folder, moved it to the desired location and it is working fine now.

有关更多详细信息和代码,请访问 http://www.rondebruin.nl/mac/mac034.htm

For more details and the code go through http://www.rondebruin.nl/mac/mac034.htm

这篇关于无法在Mac中保存为VBA中的PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆