全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 Excel
4512 7
2014-03-16
悬赏 20 个论坛币 已解决

有人可以教我写vba marco把excel 变成 PDF同时把这个文件从我的电邮发出给客户?我用outlook 的。。。老板要求我做。。。but i have no idea how to


最佳答案

jjjj6666 查看完整内容

Sub save_pdf_email() ' Don't use "/" for folder name on PC wd = InputBox("Please enter the folder name:", "Folder Name") If Right(wd, 1) "\" Then wd = wd & "\" nf = InputBox("Please enter the pdf file name:", "Filename Name") If LCase(Right(nf, 4)) ".pdf" Then nf = nf & ".pdf" nf = wd & nf ThisWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=nf ...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-3-16 01:04:13
Sub save_pdf_email()


    ' Don't use "/" for folder name on PC
    wd = InputBox("Please enter the folder name:", "Folder Name")
    If Right(wd, 1) <> "\" Then wd = wd & "\"
    nf = InputBox("Please enter the pdf file name:", "Filename Name")
    If LCase(Right(nf, 4)) <> ".pdf" Then nf = nf & ".pdf"
    nf = wd & nf
    ThisWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=nf

    'email
    Dim OutApp As Object
    Dim OutMail As Object

    mTo = InputBox("please enter the e-mail address to send the file:", "e-mail")

    If mTo <> "" Then
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
   
        On Error Resume Next
        With OutMail
            .To = mTo
            .CC = ""
            .BCC = ""
            .Subject = "PDF file saved from excel"
            .Body = "Attached please find the pdf file you requested."
            .Attachments.Add nf
            .Display
        End With
        On Error GoTo 0
   
        Set OutMail = Nothing
        Set OutApp = Nothing
    End If
End Sub
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-3-16 01:33:50
我们公司有这个,但是不能给你(版权问题).而且通过Outlook自动发送邮件出去的效果不是很好(经常无法实现). 其次我觉得要看你用的是哪个版本的EXCEL, EXCEL 2007及以上的版本都可以直接保存为PDF文件了,而且效果还不错,EXCEL2003一般需要安装别的虚拟打印机实现,推荐你可以搜索VBA代码试试的,这个问题不是很难,其实。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-3-18 13:50:29
你的excel是哪个版本啊?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-3-19 14:48:47
zcyoung08 发表于 2014-3-18 13:50
你的excel是哪个版本啊?
Excel 2010
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-3-19 16:21:55
ychu066 发表于 2014-3-19 14:48
Excel 2010
建议录制一段宏,把你要转的文档用excel存成pdf,然后用Acrobat,打开,那里面有个附件到电子邮件,默认是outlook,结束录制,然后稍作修改就搞定啦
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群