boblarson
Smeghead
- Local time
- Today, 09:09
- Joined
- Jan 12, 2001
- Messages
- 32,059
I have a db from work that used to work fine for mail merge. It would open up word and the data would be in the Word Mail Merge wizard for the users to select their mail merge fields.
Unfortunately, we had to upgrade the clients to 2007 SP1 from the base 2007. It fixed some things but it appears that it broke this.
I looked up the error (9105 String longer than 255 characters) on the MS website and it has been a problem before, but they supposedly had hot fixes, or Service Pack updates. Now it appears to be a problem in 2007 as well. Like I said, it used to work prior to the SP update.
Now I need to figure out a workaround as the clients need this ASAP.
The code that has been there is:
It fails on the doc.MailMerge.OpenDataSource part as it is 377 characters long and apparently can't be over 255. I've tried everything I know to do, including trying:
or even:
but it still reports over 255 characters.
I'm not doing well. So, maybe anyone have ideas?
Unfortunately, we had to upgrade the clients to 2007 SP1 from the base 2007. It fixed some things but it appears that it broke this.
I looked up the error (9105 String longer than 255 characters) on the MS website and it has been a problem before, but they supposedly had hot fixes, or Service Pack updates. Now it appears to be a problem in 2007 as well. Like I said, it used to work prior to the SP update.
Now I need to figure out a workaround as the clients need this ASAP.
The code that has been there is:
Code:
Private Sub Report_Open(Cancel As Integer)
If Len(Me.OpenArgs) Then
DoCmd.SetWarnings False
DoCmd.RunSQL "SELECT qry__Mailing_" & Me.OpenArgs & ".* INTO tbl_MailMerge" & Me.OpenArgs & " FROM qry__Mailing_" & Me.OpenArgs
DoCmd.SetWarnings True
Dim wd As New Word.Application
wd.Visible = True
Dim doc As Word.Document
Set doc = wd.Documents.Add
doc.MailMerge.MainDocumentType = wdFormLetters
doc.MailMerge.OpenDataSource Name:=CurrentProject.FullName, _
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=" & CurrentProject.FullName & ";Mode=Read;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=6;Jet OLEDB:Database L" _
, SQLStatement:="SELECT * FROM `tbl_MailMerge" & Me.OpenArgs & "`", SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
If doc.MailMerge.WizardState = 0 Then doc.MailMerge.ShowWizard 1, True, True, False, True, True, True
wd.Dialogs(wdDialogMailMergeRecipients).Show
End If
Cancel = True
End Sub
It fails on the doc.MailMerge.OpenDataSource part as it is 377 characters long and apparently can't be over 255. I've tried everything I know to do, including trying:
Code:
strSQL = "SELECT * FROM `tbl_MailMerge" & Me.OpenArgs
strDataSource = "Name:=CurrentProject.FullName,LinkToSource:=True,Connection:='Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=" & CurrentProject.FullName & "';SQLStatement:=" & strSQL & "'"
or even:
Code:
doc.MailMerge.OpenDataSource , , , , True, , , , , , , CurrentProject.Connection, strSQL, , , wdMergeSubTypeAccess
but it still reports over 255 characters.

I'm not doing well. So, maybe anyone have ideas?