如何在Mac上自动导出PDF?
我们在一个团队中工作。我们中的一些人在PC上,其他人在Mac上。
我想出了此潜水艇自动导出PDF(+通过PubliPosting for命名链接到Excel),它在我的PC上起作用,但在Mac上不起作用。
Sub Export_nom_lot_pdf()
'
' Export_nom_lot_pdf Macro
'
'
Dim UpDir As String
UpDir = ActiveDocument.Path
AwKN = ActiveDocument.Name
SplitAwKN = Split(AwKN, ".")
NomFichier = SplitAwKN(0)
SplitNF = Split(NomFichier, "_")
phase_nom = SplitNF(0)
lot_num = ActiveDocument.MailMerge.DataSource.DataFields(8).Value
lot_nom = ActiveDocument.MailMerge.DataSource.DataFields(9).Value
entreprise_nom = ActiveDocument.MailMerge.DataSource.DataFields(13).Value
'
ChangeFileOpenDirectory UpDir
ActiveDocument.ExportAsFixedFormat OutputFileName:=phase_nom & "_lot-" & lot_num & "_" & lot_nom & "_" & entreprise_nom, ExportFormat:=wdExportFormatPDF
Application.ScreenUpdating = True
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有说出错误发生的位置,但是代码中几乎可以肯定不起作用的一件事是呼叫
exportasFixedFormat
。如果是这样,可以说这个问题是这个问题即都不<<代码> exportasFixedFormat nor
exportasFixedFormat2
似乎在Mac上工作。从那时起,情况似乎没有改变。您可以使用saveas2
,例如,使用
exportasFixedFormat
时,不允许您使用一些可用的选项。您的代码中还有其他一些事情可能会引起问题或可能在Windows上引起问题,如果您更改为
saveas2
,例如Updir
将BE“”
,这将在ChangeFileOpendirectory
中导致错误。如果您需要在Windows和Mac版本上使用不同的代码,则可以使用“指令”来执行此操作,例如,
请参见 this 和此此以获取更多信息。
一次,从Mac上的软件创建PDF的主要方式是打印到该格式。 Mac Word的当前版本还具有与Windows Word中的用户界面选项相等的(例如,将文件发送到Microsoft Service进行转换的选项。记录
我的意见 。在那里有很多差异 - 有时很小,例如在Windows上但不是MAC上的对象属性,有时甚至更大,例如在Mac上未实现的对象,有时甚至更令人困惑的情况,其中某些事物在两个上的工作方式有所不同平台
。
You do not say where your error occurs, but the one thing in your code that will almost certainly not work is the call to
ExportAsFixedFormat
.If so, this question is arguably a duplicate of this question i.e. that neither
ExportAsFixedFormat
norExportAsFixedFormat2
seem to work on Mac. The situation does not seem to have changed since then. You can useSaveAs2
instead, e.g.That will not allow you to use some of the options that are available when using
ExportAsFixedFormat
.There are some other things in your code that could cause problems or might cause problems on Windows if you change to using
SaveAs2
, e.g.UpDir
will be""
, and that will cause an error inChangeFileOpenDirectory
.If you need to use different code on the Windows and Mac versions, you can use "directives" to do it, e.g.
See this and this for more information on that.
At one time the main way to create PDFs from software on Mac was to print to that format. The current version of Mac Word also has User Interface options equivalent to the ones in Windows Word (e.g. the option that sends the file to a Microsoft Service for conversion. So I switched on the VBA Macro Recorder and recorded that. But it didn't record anything.
Just my opinion, but if you need to write code that works on both Windows and Mac, you really need to have both types of system available to you. Microsoft's own documentation for the Office object models is primarily based on the Windows version and there are a lot of differences - sometimes quite minor, such as a an object property that's on Windows but not Mac, sometimes larger, such as objects that are not implemented on Mac, and sometimes the more confusing situation where something just works differently on the two platforms.
(Sorry,if you post comments I can't reply to them yet).