Creating a Word doc from Access and Problems with Memo field 
Author Message
 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



Thu, 28 Sep 2000 03:00:00 GMT  
 Creating a Word doc from Access and Problems with Memo field

And the function is : AppActivate <window title> [, wait]

But also look for word basic (Word 7) methods editgoto and insert
objWord.editgoto <Bookmark$>
objWord.insert     < String to insert >

Michael Whitaker heeft geschreven in bericht ...

Quote:
>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



Thu, 28 Sep 2000 03:00:00 GMT  
 Creating a Word doc from Access and Problems with Memo field

The way I do it is like this

' We are using Word from Office97
Set objWrdApp +AD0- CreateObject(+ACI-Word.Application.8+ACI-)

With objWrdApp
    .Visible +AD0- False    ' We dont want to see WORD
    .Documents.Add strTheOption    ' Variable with the name of the WORD
template
        With .ActiveDocument
            With .Bookmarks
                .Item(+ACI-TradingName+ACI-).Range.Text +AD0- strTradingName
                .Item(+ACI-Address+ACI-).Range.Text +AD0- strAddress
                .Item(+ACI-Owner+ACI-).Range.Text +AD0- strOwner
            End With
' If we have, allow background printing i.e. PrintOut Background +AD0- -1 then
' we close the document before printing has a chance to start.
            .PrintOut Background:+AD0-0, Range:+AD0-wdPrintAllDocument
            .Close savechanges:+AD0-wdDoNotSaveChanges
    End With
' Change the printing back to background so that when we are in WORD we can
still keep
' working whilst we print out a document
    .Options.PrintBackground +AD0- -1
End With

' Close WORD. We dont want to save any changes
objWrdApp.Quit savechanges:+AD0-wdDoNotSaveChanges

'Clear object
set objWrdApp +AD0- Nothing

Adrian

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



Thu, 28 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Memo fields - problems reporting 2 memo fields

2. Retrieving Access Memo Fields into a Word Document

3. Problems writing form field text in a Word Doc using WebBrowser c ontrol

4. Create Word Doc from Access??

5. automatically create word doc from access query

6. Append memo field to a different memo field

7. Access, VB, and DAO problem with a Memo Field

8. MS Access memo field problems

9. ADO, VB and Access MEMO field problem

10. Problem retrieving the memo field in Access.

11. Access 2.0, Memo-field problem

12. Problem returning data from a scroll text box to an Access memo field

 

 
Powered by phpBB® Forum Software