473,414 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Filtering a textfile datasource for mailmerging in Word

I am using the following coding:

Dim strWordDocFile As System.String = Me.txtLetter.Text
Dim WordDocFile As New System.IO.FileInfo(strWordDocFile)
Dim Msg As String
Dim strDatafile As String
Dim strQueryString As String
Dim strAlphFldName As String
Dim strFilterValue As String


strDatafile = "c:\LobbyMail\LordsList.txt"




' See if the file specified exists
If (WordDocFile.Exists) Then


Dim wordApplication As New Microsoft.Office.Interop.Word.Application
Dim wordDoc As Microsoft.Office.Interop.Word.Document = wordApplication.Documents.Open(LetterName, , True, False)

strAlphFldName = "Alph"
strFilterValue = "B"
strQueryString = "((" & """" & strAlphFldName & _
"""" & " = '" & strFilterValue & "'))"


wordDoc.MailMerge.OpenDataSource(strDatafile)
wordDoc.MailMerge.Destination = WdMailMergeDestination.wdSendToPrinter
wordDoc.MailMerge.DataSource.QueryString = "select * from " & strDatafile & " WHERE " & strQueryString


The problem is in defining wordDoc.MailMerge.DataSource.QueryString
When I place a breakpoint about this point in the coding, its value is :

"SELECT * FROM C:\LobbyMail\LordsList.txt"

so the where clause is left off. I assume it is a syntax problem.

Can anyone suggest how I can overcome this?
Jan 6 '08 #1
1 1479
CyberSoftHari
487 Expert 256MB
Can you check somewhere you are assigning again for “wordDoc.MailMerge.DataSource.QueryString =”?
Jan 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: John Spiegel | last post by:
Hey All, I'm doing something to make this fairly basic thing harder than it should be. At the end of the code below, while no exceptions are thrown and I'm getting object references, Word...
1
by: Michael Schindler | last post by:
Ich habe es nun erreicht, ein textfile einzulesen das nun zeile für zeile im datagrid angezeigt wird. Nun wäre es toll wenn ich das textfile zum beispiel nach jedem blank in eine spalte...
0
by: John Spiegel | last post by:
Hey All, I'm doing something to make this fairly basic thing harder than it should be. At the end of the code below, while no exceptions are thrown and I'm getting object references, Word...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.