Hi

Trying to run Mail Merge macro as this one:

[VBA]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 OLEDBatabase Locking Mode=0;Jet OLED" _
, SQLStatement:="SELECT * FROM `Student_List$`", SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle[/VBA]

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

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

Resolution:
HTML Code:
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 !!!