Merge from a Command button - RunTime Error 9105 - String is longer than 255 characters

I have a piece of code which I adapted from suggestions on this site.

It merges a letter in Word to an excel spreadsheet. It has been working fantastically but I have just changed the path and am getting the error message RunTime Error 9105 - String is longer than 255 characters.  Does anyone have any ideas what is going wrong?

I'd really appreciate any help you can give me
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
    ActiveDocument.MailMerge.OpenDataSource Name:= _
        "P:\CareTeamDatabase\DataSources\SourceFamily.xls", ConfirmConversions:= _
        False, ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
        PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
        WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
        Connection:= _
        "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=P:\CareTeamDatabase\DataSources\SourceFamily.xls;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Je" _
        , SQLStatement:="SELECT * FROM `Letters_Family$`", SQLStatement1:="", _
        SubType:=wdMergeSubTypeAccess
    With ActiveDocument.MailMerge
        .Destination = wdSendToNewDocument
        .SuppressBlankLines = True
        With .DataSource
            .FirstRecord = wdDefaultFirstRecord
            .LastRecord = wdDefaultLastRecord
        End With
        .Execute Pause:=False
    End With

Open in new window

PerksPAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
Does it work in manual mode (from the Word interface)?

If so, you could save the main document with the latest path, and if you don't need to change any details in your code,
you could simply automate the merge with:

ActiveDocument.MailMerge.Execute




dotofficeCommented:
try removing the un necessary arguments from this line:

"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=P:\CareTeamDatabase\DataSources\SourceFamily.xls;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Je" _
        , SQLStatement:="SELECT * FROM `Letters_Family$`", SQLStatement1:="", _
        SubType:=wdMergeSubTypeAccess


most of the time this is the issue


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PerksPAuthor Commented:
Thank you so much that did the trick
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.