PDA

View Full Version : Mail Merge - String is longer than 255 characters



gonen
05-17-2012, 01:04 AM
Hi

Trying to run Mail Merge macro as this one:

Main_loc = "d:\aagon\data\Poi\Dropbox\Miki\"
MikiExcel = Main_loc & "amiki_2011.xlsm"
ActiveDocument.MailMerge.OpenDataSource Name:=MikiExcel, _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=" & MikiExcel & ";Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Locking Mode=0;Jet OLED" _
, SQLStatement:="SELECT * FROM `Student_List$`", SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle

I get error 9105 - String is longer than 255 characters.

This is documented here :
http://support.microsoft.com/kb/298418

Resolution:

If you need to create a new data source that has more fields than can be listed in a 255 character string, you cannot use CreateDataSource to create the new file. Instead, open a new document with Documents.Add and programmatically add a table to it with all the field names that you need. Save the file and use OpenDataSource to add the new document as the data source.


Can someone help how to fix my macro with the provided solution ?




Thank you !!!