Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-18-2018, 12:12 AM
travb81 travb81 is offline MailMerge from txt file - failing when the file path contains a reserved SQL word Windows 10 MailMerge from txt file - failing when the file path contains a reserved SQL word Office 2016
Novice
MailMerge from txt file - failing when the file path contains a reserved SQL word
 
Join Date: Aug 2017
Posts: 11
travb81 is on a distinguished road
Default MailMerge from txt file - failing when the file path contains a reserved SQL word

Hiya,



I've got some VBA code that pulls some records from a database, throws them into a tab separated .txt file, and then sets up a mailmerge to that text file.
Works fantastically!

Except....
I've just been hunting for a glitch that occurred today. I've worked out that the file path contained the word 'where' in it.
eg "C:\Jobs\Timber where missing\"

Code:
        strPath = ActiveDocument.Path & "\MailMerge.txt"
        ActiveDocument.MailMerge.OpenDataSource strPath, , , True, False
        ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False
Any suggestion on how I can get around this?
I'm guessing this is because WHERE is an SQL reserved word...
If I manually do the mail merge, i get an SQL error. See image below.

I've tried to put ' or " at the start and finish of the strPath variable. No good.

The only work around is to rename the folder.
This isn't ideal - as if i go down this line, there are probably other SQL keywords that will cause problems.

Any suggestions for this unique situation?....
It is kind of a Microsoft Glitch / Bug...
Attached Images
File Type: png capture.PNG (5.1 KB, 27 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
MailMerge from txt file - failing when the file path contains a reserved SQL word Putting path and file name into all Word documents Kevin Beach Word 3 11-26-2016 06:14 PM
MailMerge from txt file - failing when the file path contains a reserved SQL word Determining file path for linked image in Word 2007 samhdc Word 7 01-26-2015 04:21 PM
MailMerge from txt file - failing when the file path contains a reserved SQL word Display Full File Path Name of Document in Title bar MS-Word 2010 Carlos06x Word 1 10-12-2011 10:39 AM
Programmatically get File Path for currently opened WORD document franferns Word 1 11-26-2009 12:36 PM
MailMerge from txt file - failing when the file path contains a reserved SQL word get file name without Path Ziggy1 Word VBA 1 09-29-2006 07:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft