
Creating a Word doc from Access and Problems with Memo field
I am trying to create a word document by using a routine that is basically
the code that is listed below. it works as planned by getting the data in
the Access form and placing it into the bookmarks in the Word document.
The hitch is that it does not work when the source of the data in the Access
form is a memo field.
My work around for this to to try and use copy/paste to get the data over
but am unable to set the focus to the Word document so that the paste code
puts the data in the correct place. I have to admitt that I am unsure if the
method that I am trying is the best, but it seems to be close to working.
I have comments through the code that may help explain the aim.
Any comments would be great.
Mike
'**********************************************************
Dim objWord As Word.Application
Dim NameAndQuals As String
Dim ConsNotes As String
Set objWord = CreateObject("word.application")
NameAndQuals =Me.Name & " " & me.Quals
ConsultNotes = Me.[Consult-Notes].Value
With objWord
.Visible = True
.Documents.Add (GetPathTowordDoc)
.ActiveDocument.Bookmarks("NameAndQuals").Select
.Selection.text = NameAndQuals
End With
Me.[Consult-Notes].SetFocus
DoCmd.RunCommand acCmdCopy
'The copy part of the routine works fine, but when it gets to the paste part
it pastes back over the top of its self
objWord.Activate 'Thus I think that this attemp to set the focus the
Word doc is not working
objWord.WindowState = wdWindowStateNormal
objWord.ActiveDocument.Bookmarks("ConsNotes").Select
DoCmd.RunCommand acCmdPaste
'After this code has run I am able to manually paste from the clipboard into
the document