+ Reply to Thread
Results 1 to 5 of 5

Mail Merge Connection String

  1. #1
    Registered User
    Join Date
    07-07-2020
    Location
    Plymouth, England
    MS-Off Ver
    2016
    Posts
    11

    Question Mail Merge Connection String

    Hey,

    I'm attempting to design a macro that will mail merge based on the row selected. I have the part where it loops through the selected row and its other details, but am struggling to create a connection string which filters it down based on this. I have tried the following:

    Please Login or Register  to view this content.
    The part that is giving me an error is the WHERE part of the statement. UPN is the column header and strUPN contains the specific UPN I'm looking for (unique pupil number - for a school). Have tried it with and without quotes etc...

    What is the correct SQL syntax to use when dealing with VBA/Excel sheets?

    Thanks in advance,

    Paul

  2. #2
    Registered User
    Join Date
    07-07-2020
    Location
    Plymouth, England
    MS-Off Ver
    2016
    Posts
    11

    Re: Mail Merge Connection String

    If it helps below is the full code I use for this:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    I activate it using the first macro and then it passes the selected rows/range to the main macro. It's still very much a work in progress and am aware that there are bugs etc. At the moment it kinda works with a minimal connection string but mail merges the whole sheet for each selected row. The saveas line is also a bit odd as it only opens a save as dialog box.

    Any help would be gratefully received.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,464

    Re: Mail Merge Connection String

    Have you tried single quote instead of backtick for string?
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-07-2020
    Location
    Plymouth, England
    MS-Off Ver
    2016
    Posts
    11

    Re: Mail Merge Connection String

    Quote Originally Posted by jindon View Post
    Have you tried single quote instead of backtick for string?
    Please Login or Register  to view this content.
    I hadn't tried that but I receive a
    Run-time error '5487': Application-define or object-defined error

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,464

    Re: Mail Merge Connection String

    I don't think that error is related to sql string.

+ 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 Issue - Extra space in a cell causing issues on the merge end
    By Karajoy in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 11-21-2023, 01:46 PM
  2. Mail Merge - Create separate Mail merge pdf for each sheets of an excel file
    By sureshbvs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2021, 12:38 PM
  3. Replies: 0
    Last Post: 11-16-2019, 09:05 AM
  4. Replies: 5
    Last Post: 11-15-2018, 10:54 PM
  5. Excel External Connection Dropping Password from Connection String?
    By mar0isa in forum Access Tables & Databases
    Replies: 1
    Last Post: 03-06-2015, 10:35 AM
  6. Replies: 0
    Last Post: 01-05-2015, 07:35 AM
  7. Replies: 2
    Last Post: 07-12-2012, 08:11 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