How do I make my form text insert at the exact bookmark location?

D

duBedat68

I have a template document that has a number of bookmarks throughtout it.
I have a UserForm that autoloads & requests the information.
When the User presses the SUBMIT button, the form text is supposed to be
transferred to specific BOOKMARKS in the document.
However, I find that the text is just inserted at the beginning of the
document, not at the required bookmarks.
I have previously made similar documents without any problems, but this one
seems to be giving me trouble. I have checked the code of this one against
other working examples & all appears to be correct.

*********************************

Private Sub cmdSubmit_Click()

strInterviewDate = txtDate.Value
strInterviewTime = txtTimeCommenced.Value
strInterviewPlace = cmbPlace.Value
strInvestigator = cmbInvestigator.Value
strInterviewee = txtInterviewee.Value
strOtherPerson1 = txtOtherPerson1.Value
strOtherPerson2 = txtOtherPerson2.Value


Selection.GoTo What = wdGoToBookmark, Name = "bmkInterviewPlace"
Selection.TypeText Text:=strInterviewPlace

frmROIDetails.Hide

End Sub

***********************************

Any advice would be greatly appreciated

duBe
 
J

Jezebel

If you're using named arguments, you have to use := to assign them -- if the
colon is missing, you're inserting a logical value instead (ie the result of
the equality); usually this just results in a runtime error, but not always,
as you've found.

To assign the value of a bookmark, set its range. Don't screw around with
Selections.

activedocument.Bookmarks("bmkInterviewPlace").Range = cmbPlace.Value


But an even better way to do this is to use DocProperties instead of
Bookmarks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top