+ Reply to Thread
Results 1 to 12 of 12

Word-Excel Mail merge

  1. #1
    Registered User
    Join Date
    02-17-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    32

    Word-Excel Mail merge

    Hope you can help come up with a solution to my problem,

    I am creating a letter template in word using mail merge to a file in excel. I have managed to set the letter up as I wanted and pulling information from excel, however I want to be able to add different signatures (name, job title, email address) depending on who sends the letter. I also want to be able to link the name to be included at certain points of the letter text.

    I have thought about fields and "IF's" but I don't really know much about these things. I thought that I could achieve this by entering first name then setting up fields to enter information based on the name etc. but although the letter is a "template" the text may need to be changed, so I cant restrict the document to just complete fields.

    Hope this makes sense!

    Anyone any thoughts?

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Word-Excel Mail merge

    I want to be able to add different signatures (name, job title, email address)
    Is ONE sender "selected" for the merge or are there multiple senders within the same merge
    - if multiple senders what determines the "sender" of each letter?


    I do not understand this
    I also want to be able to link the name to be included at certain points of the letter text.
    Are you wanting to repeat the "sender" name at various points in the letter?
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    02-17-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    32

    Re: Word-Excel Mail merge

    the roles is shared out between staff so different people could send the letter, i don't really want to create templates for each person but is this the easiest option? i wanted something a bit more techy.

    Yes so the senders name is mentioned in the body of the text so wanted it to auto fill that as well

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Word-Excel Mail merge

    Here is a method involving some basic VBA which I have tested successfully
    - create a workbook of SenderDetails (demo attached)
    - use VBA (in word document also attached) to open that workbook
    - VBA looks for match to the current user's windows UserName
    - relevant values returned
    - bookmarks placed in document to mark text insertion points

    Screenpic below of my values auto-entered at the 3 bookmarks
    AtBookmarks.jpg

    To test
    - save both files to the same folder
    - open the Excel file and add a row with your details
    - use Application.UseName to get your exact username
    - column A must match exactly otherwise you get nothing
    - save workbook and close Excel
    - open the Word document
    - {ALT}{F8} returns list of macros
    - run AddData
    - the body text of the word document now includes your details (there's confidence for you!)
    - it should be that simple (??)
    - be careful not to remove the bookmarks while you delete data when testing
    - If you accidentally delete bookmarks add them again with names BM1,BM2,BM3 to match the code

    Let me know how you get on

    Both procedures are in the same standard module of the word file
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kev_; 04-11-2018 at 12:07 PM.

  5. #5
    Registered User
    Join Date
    02-17-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    32

    Re: Word-Excel Mail merge

    Thanks Kev, really appreciate you taking the time to do this.

    Will try it tomorrow and let you know how i get on but looks to achieve exactly what i want.

  6. #6
    Registered User
    Join Date
    02-17-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    32

    Re: Word-Excel Mail merge

    Hi Kev,

    Tried this and had the following error; Compile error: can't find project or library


    any suggestions please?

  7. #7
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Word-Excel Mail merge

    Yes - you probaly noticed this
    'add reference to Excel Object library

    We are referring to Excel objects inside Word which is why we need to add a reference to the Microsoft Excel Object Library
    It is possible 2010 uses a different version to 2016
    - easy to fix

    Open up the Word File
    Go to VBA
    Click Tools \ References \
    Scroll down until you find Microsoft Excel Object Library
    Click in the box on left
    Click ok
    That's it


    ReferenceToExcel.jpg
    Last edited by kev_; 04-11-2018 at 05:07 PM.

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,830

    Re: Word-Excel Mail merge

    You really don't need a macro for this - all you need is some field coding in the mailmerge main document. For example, if you want to display the username, simply use a USERNAME field at that location. Likewise, if you want to insert some variable text depending on the username, test it with an IF field, thus:
    {IF{USERNAME}= "Joe Bloggs" "Conditional text for Joe Bloggs"}

    Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  9. #9
    Registered User
    Join Date
    02-17-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    32

    Re: Word-Excel Mail merge

    Macropod - how would you add multiple IFs?

    i.e. If username = "joe" "1"
    If username = "blogs" "2"

  10. #10
    Registered User
    Join Date
    02-17-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    32

    Re: Word-Excel Mail merge

    Also not sure how to insert the username link to the IF statement as it formats it according to the that computer so says IF "Jo" = "Jo" rather than If"username" = "jo"

    any thougths?

  11. #11
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,830

    Re: Word-Excel Mail merge

    Quote Originally Posted by MP1989 View Post
    Macropod - how would you add multiple IFs?
    I'd have thought that's be pretty obvious:
    {IF{USERNAME}= "Joe Bloggs" "Conditional text for Joe Bloggs"}{IF{USERNAME}= "Jane Doe" "Conditional text for Jane Doe"}

  12. #12
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,830

    Re: Word-Excel Mail merge

    Quote Originally Posted by MP1989 View Post
    Also not sure how to insert the username link to the IF statement as it formats it according to the that computer so says IF "Jo" = "Jo" rather than If"username" = "jo"
    Why would you not validate the usernames and use those in the IF tests? The usernames should be centrally controlled. That said, you could force an upper-case test:
    {IF{USERNAME \* Upper}= "JOE BLOGGS" "Conditional text for Joe Bloggs"}

+ 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. Mail Merge in Excel without Word
    By vikas_newports in forum Excel General
    Replies: 2
    Last Post: 01-21-2018, 09:38 AM
  2. Running Word Mail Merge from Excel 2010 - Mail Merge workbook fails
    By pl05.lau@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-05-2015, 07:35 AM
  3. Replies: 2
    Last Post: 01-22-2013, 11:37 AM
  4. Excel to Word Mail Merge
    By rfhall50 in forum Excel General
    Replies: 3
    Last Post: 02-11-2009, 01:25 PM
  5. Mail Merge from MS Excel to word
    By wei82 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-19-2007, 02:50 AM
  6. [SOLVED] mail merge from Excel to Word
    By sumplug in forum Excel General
    Replies: 2
    Last Post: 08-17-2006, 12:20 PM
  7. merge with Word How can I get excel to mail merge zip codes plus 4 correctly?
    By Kathy at Sauder Feeds in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-30-2005, 07:05 AM

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