ppkgoldengun
MIS
I've tried the following stub code (you can see some commented out tries) but I cannot get to the first cell in the table and then move between cells.
Private Sub MergeButton_Click()
Dim Letterloc As String
Dim strInsured As String
strInsured = Me.txtInsuredName
Dim db As DAO.Database
Dim rstInsured As DAO.Recordset
Set db = CurrentDb
Set rstInsured = db.OpenRecordset("qryCertDetailRedAll", dbOpenSnapshot)
rstInsured.FindFirst "[InsuredName]='" & strInsured & "'"
'Set rstInsured = db.OpenRecordset("tblEmployees", dbOpenSnapshot)
'Set rstInsured = db.OpenRecordset("qryContract", dbOpenSnapshot)
Debug.Print strInsured
Debug.Print rstInsured![InsuredName]
Debug.Print rstInsured![ExpDate]
'Debug.Print rstInsured![Certificate Description]
'Debug.Print rstInsured![InsType]
Letterloc = """" & WordLoc & """"
Set ObjWord = CreateObject("Word.Application")
With ObjWord
' Make the application visible.
.Visible = True
' Open the document.
'.Documents.Open ("c:\Access\SJSU\CertNear.dot")
.Documents.Open (Letterloc)
' Move to each bookmark and insert text from the form.
'Make sure that list follows bookmark order in Document.
.ActiveDocument.Bookmarks("InsuredName").Select
.Selection.Text = (CStr(rstInsured![InsuredName]))
.ActiveDocument.Bookmarks("InsuredAddress").Select
.Selection.Text = (CStr(rstInsured![InsuredAddress]))
.ActiveDocument.Bookmarks("InsuredCity").Select
.Selection.Text = (CStr(rstInsured![InsuredCity]))
.ActiveDocument.Bookmarks("InsuredCode").Select
.Selection.Text = (CStr(rstInsured![InsuredCode]))
.ActiveDocument.Bookmarks("InsuredZip").Select
.Selection.Text = (CStr(rstInsured![InsuredZip]))
.ActiveDocument.Bookmarks("InsuredContact").Select
.Selection.Text = (CStr(rstInsured![InsuredName]))
.Selection.GoTo What:=wdGoToTable, Which:=wdGoToNext
'.ActiveDocument.Bookmarks("FirstCell").Select
'.selection.TypeText Text:="RowOneColumnOne"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowOneColumnTwo"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowoneColumn3"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowoneColumnfour"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowtwoColumnOne"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowtwoColumnTwo"
ObjWord.Selection.WholeStory
ObjWord.Selection.HomeKey Unit:=6
With ObjWord.Selection
.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=1, Name:=""
.MoveDown Unit:=wdLine, Count:=1
End With
Private Sub MergeButton_Click()
Dim Letterloc As String
Dim strInsured As String
strInsured = Me.txtInsuredName
Dim db As DAO.Database
Dim rstInsured As DAO.Recordset
Set db = CurrentDb
Set rstInsured = db.OpenRecordset("qryCertDetailRedAll", dbOpenSnapshot)
rstInsured.FindFirst "[InsuredName]='" & strInsured & "'"
'Set rstInsured = db.OpenRecordset("tblEmployees", dbOpenSnapshot)
'Set rstInsured = db.OpenRecordset("qryContract", dbOpenSnapshot)
Debug.Print strInsured
Debug.Print rstInsured![InsuredName]
Debug.Print rstInsured![ExpDate]
'Debug.Print rstInsured![Certificate Description]
'Debug.Print rstInsured![InsType]
Letterloc = """" & WordLoc & """"
Set ObjWord = CreateObject("Word.Application")
With ObjWord
' Make the application visible.
.Visible = True
' Open the document.
'.Documents.Open ("c:\Access\SJSU\CertNear.dot")
.Documents.Open (Letterloc)
' Move to each bookmark and insert text from the form.
'Make sure that list follows bookmark order in Document.
.ActiveDocument.Bookmarks("InsuredName").Select
.Selection.Text = (CStr(rstInsured![InsuredName]))
.ActiveDocument.Bookmarks("InsuredAddress").Select
.Selection.Text = (CStr(rstInsured![InsuredAddress]))
.ActiveDocument.Bookmarks("InsuredCity").Select
.Selection.Text = (CStr(rstInsured![InsuredCity]))
.ActiveDocument.Bookmarks("InsuredCode").Select
.Selection.Text = (CStr(rstInsured![InsuredCode]))
.ActiveDocument.Bookmarks("InsuredZip").Select
.Selection.Text = (CStr(rstInsured![InsuredZip]))
.ActiveDocument.Bookmarks("InsuredContact").Select
.Selection.Text = (CStr(rstInsured![InsuredName]))
.Selection.GoTo What:=wdGoToTable, Which:=wdGoToNext
'.ActiveDocument.Bookmarks("FirstCell").Select
'.selection.TypeText Text:="RowOneColumnOne"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowOneColumnTwo"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowoneColumn3"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowoneColumnfour"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowtwoColumnOne"
'.selection.MoveRight Unit:=wdCell
'.selection.TypeText Text:="RowtwoColumnTwo"
ObjWord.Selection.WholeStory
ObjWord.Selection.HomeKey Unit:=6
With ObjWord.Selection
.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=1, Name:=""
.MoveDown Unit:=wdLine, Count:=1
End With