ppkgoldengun
MIS
Hi,
Have used book marks in the past to do a mail merge for a single record into a word temple. Works great. However, I am now faced with moving through a record set (using finds) and for a particular vendor listing once their name address, etc. Still works great with book marks. However, I then need to create a word table with the additional rows of information that the recordset includes. I have little knowledge of VBA as it pertains to word. I've stubbed out the following code that blows up in moving to the next cell in the table (I've created a single row table with a bookmark in the first cell). I believe its becuase I am using a selection object. I also want to create a new row when I find another record for the vendor and obviously move to that new row, first cell, move next cell, etc. etc. Any help would be greatly appreciated. My stubbed code (their is some early db open, open word app stuff before this.... How do I move next cell? How do I place a recordset value into that cell if it is not a bookmark?
.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]))
Do While Not rstInsured.EOF
' .Selection.GoTo What:=wdGoToBookmark, Name:="FirstCell"
.ActiveDocument.Bookmarks("FirstCell").Select
.Selection.Text = (CStr(rstInsured![PurchaseOrder]))
Selection.Next(Unit:=wdCell, Count:=1).Select
.Selection.Text = (CStr(rstInsured![Certificate Description]))
.Selection.MoveRight Unit:=wdCell
.Selection.Text = (CStr(rstInsured![InsType]))
.Selection.MoveRight Unit:=wdCell
.Selection.Text = (CStr(rstInsured![ExpDate]))
.Selection.InsertRowsBelow 1
.Selection.MoveRight Unit:=wdCell
Have used book marks in the past to do a mail merge for a single record into a word temple. Works great. However, I am now faced with moving through a record set (using finds) and for a particular vendor listing once their name address, etc. Still works great with book marks. However, I then need to create a word table with the additional rows of information that the recordset includes. I have little knowledge of VBA as it pertains to word. I've stubbed out the following code that blows up in moving to the next cell in the table (I've created a single row table with a bookmark in the first cell). I believe its becuase I am using a selection object. I also want to create a new row when I find another record for the vendor and obviously move to that new row, first cell, move next cell, etc. etc. Any help would be greatly appreciated. My stubbed code (their is some early db open, open word app stuff before this.... How do I move next cell? How do I place a recordset value into that cell if it is not a bookmark?
.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]))
Do While Not rstInsured.EOF
' .Selection.GoTo What:=wdGoToBookmark, Name:="FirstCell"
.ActiveDocument.Bookmarks("FirstCell").Select
.Selection.Text = (CStr(rstInsured![PurchaseOrder]))
Selection.Next(Unit:=wdCell, Count:=1).Select
.Selection.Text = (CStr(rstInsured![Certificate Description]))
.Selection.MoveRight Unit:=wdCell
.Selection.Text = (CStr(rstInsured![InsType]))
.Selection.MoveRight Unit:=wdCell
.Selection.Text = (CStr(rstInsured![ExpDate]))
.Selection.InsertRowsBelow 1
.Selection.MoveRight Unit:=wdCell