简体   繁体   English

访问 2010 PDF,使用 VBA 代码保存和通过电子邮件发送报告

[英]Access 2010 PDF, Save and Email a Report Using VBA Code

I'm using Access 2010 and found the Send to Email as PDF command indispensable.我正在使用 Access 2010,发现“以 PDF 格式发送到电子邮件”命令必不可少。 However, I have a problem in that I've hidden the main ribbon from my users which means they can't actually click that button.但是,我有一个问题,因为我对用户隐藏了主功能区,这意味着他们实际上无法单击该按钮。

Can anyone tell me the VBA code that will let me PDF, save the file and email via Gmail an individual report based on a given unique ID?谁能告诉我 VBA 代码可以让我 PDF、保存文件并通过 Gmail 通过电子邮件发送基于给定唯一 ID 的个人报告? I am happy for the user to add the email address, subject and message body and for them to click send.我很高兴用户添加电子邮件地址、主题和邮件正文,并让他们单击发送。

I begin with the following code, but it doesn't work.我从以下代码开始,但它不起作用。

Dim myPath As String
Dim strReportName As String

DoCmd.OpenReport "rptsuivi", acViewPreview, , "tblsuivi.[N°Suivi] = '" & Me.[CompanyName] & "' "

myPath = "C:\"
strReportName = "Raport de suivi" + "-" + ".pdf"

DoCmd.OutputTo acOutputReport, acFormatPDF, , myPath + strReportName, True
DoCmd.Close acReport, "rptsuivi"

looks like you can create a macro that just runs the ribbon command看起来你可以创建一个只运行功能区命令的宏

https://msdn.microsoft.com/en-us/library/office/ff862419.aspx https://msdn.microsoft.com/en-us/library/office/ff862419.aspx

http://www.ribboncreator2010.de/Onlinehelp/EN/_2el0osmon.htmhttp://www.ribboncreator2010.de/Onlinehelp/EN/_2el0osmon.htm

you'll need to find the right idMso for the ribbon function you're trying to use.您需要为您尝试使用的功能区功能找到正确的 idMso。

Sub SendToEmailAsPDF()

Application.CommandBars.ExecuteMso "FileSendAsAttachment"

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM