楼主: ychu066
4200 7

[问答] vba marco把excel 变成 PDF [推广有奖]

  • 0关注
  • 5粉丝

等待验证会员

博士生

16%

还不是VIP/贵宾

-

威望
0
论坛币
1563 个
通用积分
1.7552
学术水平
35 点
热心指数
31 点
信用等级
32 点
经验
3787 点
帖子
123
精华
1
在线时间
131 小时
注册时间
2009-2-9
最后登录
2020-2-12

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 ...
关键词:marco EXCEL exce Marc xcel excel false Style
沙发
jjjj6666 发表于 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

使用道具

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

使用道具

板凳
zcyoung08 发表于 2014-3-18 13:50:29 |只看作者 |坛友微信交流群
你的excel是哪个版本啊?

使用道具

报纸
ychu066 发表于 2014-3-19 14:48:47 |只看作者 |坛友微信交流群
zcyoung08 发表于 2014-3-18 13:50
你的excel是哪个版本啊?
Excel 2010

使用道具

地板
zcyoung08 发表于 2014-3-19 16:21:55 |只看作者 |坛友微信交流群
ychu066 发表于 2014-3-19 14:48
Excel 2010
建议录制一段宏,把你要转的文档用excel存成pdf,然后用Acrobat,打开,那里面有个附件到电子邮件,默认是outlook,结束录制,然后稍作修改就搞定啦

使用道具

7
ychu066 发表于 2014-3-24 21:24:49 |只看作者 |坛友微信交流群
我公司其实是用Lotus notes 8.5的,不是outlook ...

使用道具

8
金桥 发表于 2014-3-26 12:41:42 |只看作者 |坛友微信交流群
no zuo no die!

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-28 23:27