Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / April 2007

Tip: Looking for answers? Try searching our database.

My first Word Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bcjc18433@gmail.com - 09 Apr 2007 00:01 GMT
Any one know what this won't work?
I have  a .xlsm file that stores the source for my merge.
I connect to it using the "Select Recipients --> Use Existing List"
option on the "Mailings" Ribbon.
Connection works great.

But when I run the code below. I lose the connection to the .xlsm file
after getting "Run-time Error '4198': Command Failed"

ActiveDocument.MailMerge.DataSource.QueryString = "SELECT * FROM C:
\Documents and Settings\brian_summers\Favorites\Links\Account Tools\My
Space Files\Mail Merge Files\All Accounts (Excel 2007).xlsm WHERE
(rep_id = 12345)"

Thanks in advance,

Brian
Peter Jamieson - 09 Apr 2007 08:22 GMT
Word has several ways to connect to an Excel sheet. By default in Word 2007
it uses OLE DB. If you have already connected using that method then
a. I don't think you will be able to change the name of the workbook using
Querystring, if that is one of the things you are doing
b. your query probably needs to specify the sheet or names range name,
rather than the workbook pathname, e.g.

ActiveDocument.MailMerge.DataSource.QueryString = _
"SELECT * FROM [mysheetname$] WHERE (rep_id = 12345)"

sustituting your sheetname for mysheetname$

However, I can't check here. It might help if you could use the VBA editor's
immediate window to issue the following commands /before/ you try to change
anything:
print ActiveDocument.MailMerge.DataSource.Name
print ActiveDocument.MailMerge.DataSource.ConnectString
print ActiveDocument.MailMerge.DataSource.QueryString

You may also eventually have to take account of the following article:

http://support.microsoft.com/kb/825765

Peter Jamieson

> Any one know what this won't work?
> I have  a .xlsm file that stores the source for my merge.
[quoted text clipped - 13 lines]
>
> Brian
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.