Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selection won't move to table and then move between cells

Status
Not open for further replies.
May 5, 2002
79
US
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
 
Hi,

Try something like this
Code:
With activedocument.tables(1)
  .Cells(1,1).text = "RowOneColumnOne"
...
end with


Skip,
[sub]
[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top