D
DRBE
Thanks for all previous help, and patience with my lack of skills. I am
using the code below to insert fields from my database into a Preformatted
Word Doc.
It has been working great, except now, the fields I need to insert are from
"memo" fields and greater than 255 chars. It works fine if shorter, but as
soon as there are too many characters, when I run the command, instead of
opening the "merged" document, I am asked if I want to "save as" document1.
If I do this, the document opens, but the field that is too long, has not
been inserted, and when I close the document I get the error "string
parameter too long".
Any advice on how to get around this would be appreciated.
Thanks in anticipation
Kind regards
Bruce
This is in a module, and then the function called from the form.
Public Sub PrintMLReport(vID As Long, vID2 As Long, vFilename As String)
Dim objWord As Word.Application
Dim ExpIDrep, RepIDrep, WorkDetrst As DAO.Recordset
On Error GoTo ErrorCode
'Start MS Word and open specified document
Set objWord = New Word.Application
objWord.Documents.Add vFilename
objWord.ScreenUpdating = True
Set AccidRst = CurrentDb.OpenRecordset("SELECT * " _
& "FROM [2AccidentDetailsTable] WHERE ReportID = " & vID2)
ReplaceText objWord, "[AccidentSumm]", Nz(AccidRst![Summary])
objWord.ScreenUpdating = True
objWord.ActiveDocument.Saved = True
objWord.Visible = True
Set objWord = Nothing
Exit Sub
ErrorCode:
objWord.Quit
MsgBox Err.Description
End Sub
Public Sub ReplaceText(obj As Word.Application, vSource As String, vDest As
String)
'Replace all occurences of vSource with vDest in Word doc
obj.ActiveDocument.Content.Find.Execute FindText:=vSource, _
ReplaceWith:=vDest, Format:=True, _
Replace:=wdReplaceAll
End Sub
using the code below to insert fields from my database into a Preformatted
Word Doc.
It has been working great, except now, the fields I need to insert are from
"memo" fields and greater than 255 chars. It works fine if shorter, but as
soon as there are too many characters, when I run the command, instead of
opening the "merged" document, I am asked if I want to "save as" document1.
If I do this, the document opens, but the field that is too long, has not
been inserted, and when I close the document I get the error "string
parameter too long".
Any advice on how to get around this would be appreciated.
Thanks in anticipation
Kind regards
Bruce
This is in a module, and then the function called from the form.
Public Sub PrintMLReport(vID As Long, vID2 As Long, vFilename As String)
Dim objWord As Word.Application
Dim ExpIDrep, RepIDrep, WorkDetrst As DAO.Recordset
On Error GoTo ErrorCode
'Start MS Word and open specified document
Set objWord = New Word.Application
objWord.Documents.Add vFilename
objWord.ScreenUpdating = True
Set AccidRst = CurrentDb.OpenRecordset("SELECT * " _
& "FROM [2AccidentDetailsTable] WHERE ReportID = " & vID2)
ReplaceText objWord, "[AccidentSumm]", Nz(AccidRst![Summary])
objWord.ScreenUpdating = True
objWord.ActiveDocument.Saved = True
objWord.Visible = True
Set objWord = Nothing
Exit Sub
ErrorCode:
objWord.Quit
MsgBox Err.Description
End Sub
Public Sub ReplaceText(obj As Word.Application, vSource As String, vDest As
String)
'Replace all occurences of vSource with vDest in Word doc
obj.ActiveDocument.Content.Find.Execute FindText:=vSource, _
ReplaceWith:=vDest, Format:=True, _
Replace:=wdReplaceAll
End Sub