Option Compare Database
Option Explicit
' From "Microsoft Access 2000 Development Unleashed" (SAMS)
' By: Forte, Howe, Ralston
Public Sub Vozzakl()
' The purpose of this example is to show how Access data
' is inserted into a Word document with Find and Replace.
' This is a rather complicated Word document with text wrapped
' around photos. This document would be difficult to create
' with an Access report.
' Use GetObject to use an instance of the application if it is
' already running; otherwise, create a new instance of the applicaton.
Dim objWord As Word.Application
Dim DB As Database
Dim RS As Recordset
'* Подойдет ли данная формулировка для запроса а не таблица
' Turn hourglass on.
Screen.MousePointer = 11
' Resume to the next line following the error.
On Error Resume Next
' Attempt to reference Word which is already running.
Set objWord = GetObject(, "Word.Application")
' If true, Word is not running.
If objWord Is Nothing Then
' Create a new instance of the Word application.
Set objWord = New Word.Application
' If true, MS Word is not installed.
If objWord Is Nothing Then
MsgBox "MS Word is not installed on your computer"
End If
End If
' On Error GoTo ErrorHandler (Put Error Handler Code Here!)
' Set RS equal to the Products table in the current database.
Set RS = CurrentDb.OpenRecordset("11", dbOpenDynaset)
'* Можно ли в рекордсет помещать результат запроса?
objWord.Documents.Add (CurrentProject.Path & "\vozzakl.dot")
'* подключаем шаблон
'
' Set the recordset index to the Product Name index so that the
' seek method can be used.
RS.Index = "№"
Dim i As Integer
Dim s(9) As String
Dim t(9) As String
s(1) = "{FKP}"
t(1) = Str(RS![сделка.предприятие
![]()
])
'* нужно в т занести поля запроса
s(2) = "{predpriyatie}"
't(2)=
s(3) = "{adres}"
't(3)=
s(4) = "{FKP}"
't(4)=
s(5) = "{predpriyatie}"
't(5)=
s(6) = "{data}"
't(6)=
s(7) = "{#}"
't(7)=
s(8) = "{doljnost}"
't(8)=
s(9) = "{zaveril}"
't(9)=
For i = 1 To 9
'Find the record
RS.Seek "=", s(i)
objWord.Selection.Find.ClearFormatting
objWord.Selection.Find.Replacement.ClearFormatting
With objWord.Selection.Find
.Text = s(i)
.Replacement.Text = t(i) '****************
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Next
' Find the FKP record
' RS.Seek "=", "{FKP}"
' objWord.Selection.Find.ClearFormatting
' objWord.Selection.Find.Replacement.ClearFormatting
' With objWord.Selection.Find
' .Text = "{FKP}"
' .Replacement.Text = Str(RS![Сделка.предприятие]) '****************
' .Forward = True
' .Wrap = wdFindContinue
' .Format = False
' .MatchCase = False
' .MatchWholeWord = False
' .MatchWildcards = False
' .MatchSoundsLike = False
' .MatchAllWordForms = False
' End With
' Move the cursor to the top of the document.
objWord.Selection.HomeKey Unit:=wdStory
DoEvents
' Turn hourglass off.
Screen.MousePointer = 0
' Activates Word
objWord.Activate
' Show Word to the user.
objWord.Visible = True
RS.Close
DB.Close
Set RS = Nothing
Set DB = Nothing
Set objWord = Nothing
End Sub
запрос из которого нужно взять информацию.

не знаком с VBA.
Помогите по возможносте.
Заранее благодарен
http://www.sql.ru/forum/1112877/neobhodima-pomoshh