如何自动邮件合并文件名称中的变量? [英] How to mail merge a file with a variable in its name automatically?

查看:217
本文介绍了如何自动邮件合并文件名称中的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每天收到一个包含电子邮件列表的excel文件,我需要将文件邮寄到这些电子邮件中。 excel表的名称总是完全相同,但最后日期除外,即今天的费率资格09.10.15和明天的费率
资格09.11.15。我正在尝试设置一个宏,将自动将此文档发送到新的日期列表。 

Every day I receive a excel file with a list of emails on it, and I need to mail out a document to those emails. The name of the excel sheet is always the exact same with the exception of the date at the end i.e. Rate Qualification 09.10.15 today and  Rate Qualification 09.11.15 tomorrow. I am trying to set a macro that will send this document to the days new list automatically. 

这是我到目前为止所拥有的:

Here is what I have so far:

Sub RQT2()
'
' RQT2 Macro
'
'

Dim TD As String

TD = Format(Date, "mm.dd.yy")
RQES = "'D:\Rate_Qualification_Emails_' & TD & '.xlsx'"
    ActiveDocument.MailMerge.OpenDataSource Name:= _
        RQES _
        , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
        AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
        WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
        Format:=wdOpenFormatAuto, Connection:= _
        "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=RQES;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OL" _
        , SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="", SubType:= _
        wdMergeSubTypeAccess
    With ActiveDocument.MailMerge
        .Destination = wdSendToEmail
        .SuppressBlankLines = True
        With .DataSource
            .FirstRecord = wdDefaultFirstRecord
            .LastRecord = wdDefaultLastRecord
        End With
        .Execute Pause:=False
    End With


此代码几乎可以工作,但会打开确认数据源的请求。帮助不大?拜托,谢谢。

This code almost works, but opens a request to confirm data source. Little help? please and thank you.

推荐答案

代码"几乎不能正常工作"。它涉及三个应用程序(Outlook,Word和Excel)并且没有正确地解决它们中的任何一个。

The code doesn't 'almost work'. It involves three applications (Outlook, Word and Excel) and doesn't properly address any of them.

您想从这三个应用程序中运行此代码中的哪一个?如果您将工作表作为电子邮件附件接收,则从Outlook运行它是有意义的,因为它可以自动运行。然后这个名称无关紧要,因为附加到收到的消息的工作簿是

Which of the three applications do you want to run this code from? If you are receiving the worksheet as an e-mail attachment, it would make sense to run it from Outlook, as it could then be run automatically. Then the name wouldn't matter so much as it's the workbook attached to the received message.

无论这是否可行,我们仍然必须确定文件是什么您通过电子邮件发送到该工作簿中的地址。它是代码暗示的邮件合并吗?该邮件的数据是否合并到工作簿中?

Whether or not that is possible, we still have to establish what the document is that you are e-mailing to the addresses in that workbook. Is it a mail merge as your code implies? Is the data for that mail merge in the workbook?

如果这两个问题的答案都是肯定的,那么可能会节省一些时间来使用
http://www.gmayor.com/ManyToOne.htm 功能在一对一模式。如果没有,那么让我们确切地知道你要做什么以及'文件'的性质。

If the answer to both those questions is yes, then it might save you some time to use http://www.gmayor.com/ManyToOne.htm  in one to one mode. If not then let us know exactly what you are trying to do and the nature of the 'document'.


这篇关于如何自动邮件合并文件名称中的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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