Newsgroup: it.comp.appl.access
Titolo: aprire da acces un file word e far inserire i dati del record corrente

Grazie.
Non trovato nelle News.
Come posso far aprire un file di Word e nei campi di unione far inserire
automaticamente i dati del record corrente al fine di preformatare il file e
poi aggiungere dati e/o modificarli.
Grazie ancora.
Bruno

 Bruno
ciao io uso questo metodo ed è ottimo, naturalmente devi modificare qlcsa,
e magari anche cancellare alcune cose che non ti interessa... fammi
sapere! 
Private Sub MergeButton_Click()
      On Error GoTo MergeButton_Err
         Dim objWord As Word.Application
         ' Copy the Photo control on the Employees form.
         DoCmd.GoToControl "Photo"
         ' Remove the following comment in Microsoft Access 97.
         ' DoCmd.RunCommand acCmdCopy
         ' Remove the following comment in Microsoft Access 7.0.
         ' DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy, , acMenuVer70
         ' Start Microsoft Word 97.
         Set objWord = CreateObject("Word.Application")
         With objWord
            ' Make the application visible.
            .Visible = True
            ' Open the document.
            .Documents.Open ("c:\my documents\mymerge.doc")
            ' Move to each bookmark and insert text from the form.
            .ActiveDocument.Bookmarks("First").Select
            .Selection.Text = (CStr(Forms!Employees!FirstName))
            .ActiveDocument.Bookmarks("Last").Select
            .Selection.Text = (CStr(Forms!Employees!LastName))
            .ActiveDocument.Bookmarks("Address").Select
            .Selection.Text = (CStr(Forms!Employees!Address))
            .ActiveDocument.Bookmarks("City").Select
            .Selection.Text = (CStr(Forms!Employees!City))
            .ActiveDocument.Bookmarks("Region").Select
            .Selection.Text = (CStr(Forms!Employees!Region))
            .ActiveDocument.Bookmarks("PostalCode").Select
            .Selection.Text = (CStr(Forms!Employees!PostalCode))
            .ActiveDocument.Bookmarks("Greeting").Select
            .Selection.Text = (CStr(Forms!Employees!FirstName))
            ' Paste the photo.
            .ActiveDocument.Bookmarks("Photo").Select
            .Selection.Paste
         End With
         ' Print the document in the foreground so Microsoft Word 97
         ' will not close until the document finishes printing.
         objWord.ActiveDocument.PrintOut Background:=False
         ' Close the document without saving changes.
         objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
         ' Quit Microsoft Word 97 and release the object variable.
         objWord.Quit
         Set objWord = Nothing
         Exit Sub
      MergeButton_Err:
         ' If a field on the form is empty
         ' remove the bookmark text and continue.
         If Err.Number = 94 Then
            objWord.Selection.Text = ""
            Resume Next
         ' If the Photo field is empty.
         ElseIf Err.Number = 2046 Then
            MsgBox "Please add a photo to this record and try again."
         Else
            MsgBox Err.Number & vbCr & Err.Description
         End If
         Exit Sub
      End Sub
-- 
questo articolo e` stato inviato via web dal servizio gratuito 
http://www.newsland.it/news
 segnala gli abusi ad 
ab...@newsland.it