R
rogge
is there a method to use docWord.Bookmarks(i).Range.Text or
docWord.FormFields(i).Range.Text without deleting the bookmark or field?
______________________________________________
Hear Ye!, Hear Ye! I am a bit lazy and do not like to type code. So I
thought, "What if i put the fields in a DAO.Recordset in the same order that
the data would appear in MS Word. Then i could loop through the bookmarks
and fields while using the same code to enter text. This would be great!"
I am using MS Access to place text into a word document. I have tried
bookmarks and fields, but when "docWord.Bookmarks(i).Range.Text =
rds.Fields(i).Value" then the bookmark or field is deleted causing the data
to be placed into the incorret spot and not completing the transfer.
I know i can use direct references:
docWord.Bookmarks("nameTo").Range.Text = rds.Fields("nameTo").Value
- or the bookmarks can be numbered sequentially:
docWord.Bookmarks("bkm" & i).Range.Text = rds.Fields(i).Value
- or one can just type the document from scratch,
But as i said earlier i am LAZY and would bery much prefer to use a loop and
not have to worry about properly naming bookmarks to coincide with field
names.
For i = 1 To docWord.Bookmarks.Count
docWord.Bookmarks(i).Range.Text = rds.Fields(i).Value
Next i
________________________________________________
For i = 1 To docWord.FormFields.Count
docWord.FormFields(i).Range.Text = rds.Fields(i).Value
Next i
This code runs, umm, err, 'fine (?)' except that the bookmarks or fields are
re-numbered as the bookmarks and fields are deleted and this causes data to
be placed improperly in the word document. Any "no", i do not run both of
these. I am only using fields or bookmarks.
Thank you veyr much.
docWord.FormFields(i).Range.Text without deleting the bookmark or field?
______________________________________________
Hear Ye!, Hear Ye! I am a bit lazy and do not like to type code. So I
thought, "What if i put the fields in a DAO.Recordset in the same order that
the data would appear in MS Word. Then i could loop through the bookmarks
and fields while using the same code to enter text. This would be great!"
I am using MS Access to place text into a word document. I have tried
bookmarks and fields, but when "docWord.Bookmarks(i).Range.Text =
rds.Fields(i).Value" then the bookmark or field is deleted causing the data
to be placed into the incorret spot and not completing the transfer.
I know i can use direct references:
docWord.Bookmarks("nameTo").Range.Text = rds.Fields("nameTo").Value
- or the bookmarks can be numbered sequentially:
docWord.Bookmarks("bkm" & i).Range.Text = rds.Fields(i).Value
- or one can just type the document from scratch,
But as i said earlier i am LAZY and would bery much prefer to use a loop and
not have to worry about properly naming bookmarks to coincide with field
names.
For i = 1 To docWord.Bookmarks.Count
docWord.Bookmarks(i).Range.Text = rds.Fields(i).Value
Next i
________________________________________________
For i = 1 To docWord.FormFields.Count
docWord.FormFields(i).Range.Text = rds.Fields(i).Value
Next i
This code runs, umm, err, 'fine (?)' except that the bookmarks or fields are
re-numbered as the bookmarks and fields are deleted and this causes data to
be placed improperly in the word document. Any "no", i do not run both of
these. I am only using fields or bookmarks.
Thank you veyr much.