+ Reply to Thread
Results 1 to 5 of 5

Need help from expert!!

Hybrid View

  1. #1
    Registered User
    Join Date
    07-09-2015
    Location
    United States
    MS-Off Ver
    2013
    Posts
    52

    Need help from expert!!

    I really need help with this macro:

    Sub MailMergeTest1()
    '
    ' MailMergeTest1 Macro
    '
    '



    ActiveDocument.MailMerge.OpenDataSource Name:= _
    "\\158.555.555.33\Savannah\Schedules\2 DEMO Complete\7.13..15_FMAT_Schedule.xlsm" _
    , 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=\\158.555.555.33\Savannah\Schedules\2 DEMO Complete\7.13..15_FMAT_Schedule.xlsm;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:E" _
    , SQLStatement:="SELECT * FROM `Schedule$`", SQLStatement1:="", SubType:= _
    wdMergeSubTypeAccess
    With ActiveDocument.MailMerge
    .Destination = wdSendToNewDocument
    .SuppressBlankLines = True
    With .DataSource
    .FirstRecord = wdDefaultFirstRecord
    .LastRecord = wdDefaultLastRecord
    End With
    .Execute Pause:=False
    End With
    End Sub

    In the blue text above I need to make the date automatically pull up yesterdays date. So if today is May 2nd, then I need it to pull up 5.1..15_FMAT_Schedule

    Thanks and let me know if you need any more information.

  2. #2
    Registered User
    Join Date
    07-15-2015
    Location
    South East England
    MS-Off Ver
    2010 & 2013
    Posts
    72

    Re: Need help from expert!!

    Sub MailMergeTest1()
     
     ' MailMergeTest1 Macro
    
    Dim Yesterday As String ' D.M..YY
    
    Yesterday = Month(Date - 1)
    Yesterday = Yesterday & "."
    Yesterday = Yesterday & Day((Date - 1)) & ".."
    Yesterday = Yesterday & Right(Year(Date - 1), 2)
    
     ActiveDocument.MailMerge.OpenDataSource Name:= _
    "\\158.555.555.33\Savannah\Schedules\2 DEMO Complete\" & Yesterday & "_FMAT_Schedule.xlsm" _
     , 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=\\158.555.555.33\Savannah\Schedules\2 DEMO Complete\" & Yesterday & "_FMAT_Schedule.xlsm;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:E" _
     , SQLStatement:="SELECT * FROM `Schedule$`", SQLStatement1:="", SubType:= _
     wdMergeSubTypeAccess
     
     With ActiveDocument.MailMerge
     .Destination = wdSendToNewDocument
     .SuppressBlankLines = True
     With .DataSource
     .FirstRecord = wdDefaultFirstRecord
     .LastRecord = wdDefaultLastRecord
     End With
     .Execute Pause:=False
     End With
     
     
     
     End Sub

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,640

    Re: Need help from expert!!

    Also read forum rules about code tags

  4. #4
    Registered User
    Join Date
    07-09-2015
    Location
    United States
    MS-Off Ver
    2013
    Posts
    52

    Re: Need help from expert!!

    Thank you soooo much!

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,640

    Re: Need help from expert!!

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How To put Numbers in Sequence in Excel
    By sami8086 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2015, 03:47 PM
  2. Not-So-Expert Excel Expert
    By HeyLucy in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 01-25-2013, 01:49 PM
  3. i'm not an expert
    By elizabeth7811 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 10-11-2012, 07:10 PM
  4. help...i need an expert
    By battousai9 in forum Excel General
    Replies: 2
    Last Post: 06-03-2009, 11:46 AM
  5. Need your expert help
    By krokodilos75 in forum Excel General
    Replies: 3
    Last Post: 01-21-2009, 07:41 AM
  6. I need an expert for that!
    By mhax in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-19-2006, 09:00 AM
  7. What is an expert?
    By tony h in forum Excel General
    Replies: 6
    Last Post: 02-07-2006, 11:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1