K
Katherine
Me again. My userform fills out an enormous number of bookmarks in a
structured document (which will then be imported into another program). The
user wants to be able to reopen the document and have it automatically
populate the userform with what they entered last time, so they only have to
edit it rather than retype it all.
No problem, I thought - just use userform_initialize to set the value of
each textbox/combobox with the value from the relevant bookmark in the
document. I've used this:
If ActiveDocument.Bookmarks("bmkPrice1").Range.Text = "" Then Exit Sub
--If they have filled the form in before, this bookmark won't be blank, so
I'm checking it first and not bothering with the rest of the sub if the
bookmark is blank
For i = 1 To 48
Me.Controls("txtAgencyRef" & CStr(i)).Value = ActiveDocument.Bookmarks _
("bmkAgencyRef" & CStr(i)).Range.Text
Next i
To all intents and purposes, this works. Problem is, it's feasible for some
bookmarks to be blank and when they are, the userform is pulling in a
paragraph mark or a space (because that's whats currently inside the bookmark
I guess).
It's doing what I tell it to do but this isn't what I want (typical woman,
huh?) - is there any other way I can pull in just the text from inside the
bookmark?
Because the doc is designed to work to the specifications of the program
it's going to be imported into, I can't get rid of the carriage returns in
the doc, which is structured something like this:
###AgencyRef1
[bookmark]
#Price1
[bookmark]
....etc
Also....
Submitting the edited details by clicking the command button is appending
the value of the controls to what is already in each bookmark - which is,
again, no good. I could clear all the bookmarks before entering the values in
them, but as the user is only going to be editing the userform contents this
may lead me to wipe out information that is actually needed.
This is an example of the type of thing I have coded onto the command
button, just in case you can see any rookie errors or 'stupid thinking':
For i = 1 To 48
ActiveDocument.Bookmarks("bmkAgencyRef" & CStr(i)).Range _
..InsertBefore Me.Controls("txtAgencyRef" & CStr(i)).Text
Next i
Can anyone think of a way round this? Am I a hopeless case? Shall I just
give up and tell the user to "Do it your @~#! self!" ? Anyone shedding any
light is welcome to my firstborn.
structured document (which will then be imported into another program). The
user wants to be able to reopen the document and have it automatically
populate the userform with what they entered last time, so they only have to
edit it rather than retype it all.
No problem, I thought - just use userform_initialize to set the value of
each textbox/combobox with the value from the relevant bookmark in the
document. I've used this:
If ActiveDocument.Bookmarks("bmkPrice1").Range.Text = "" Then Exit Sub
--If they have filled the form in before, this bookmark won't be blank, so
I'm checking it first and not bothering with the rest of the sub if the
bookmark is blank
For i = 1 To 48
Me.Controls("txtAgencyRef" & CStr(i)).Value = ActiveDocument.Bookmarks _
("bmkAgencyRef" & CStr(i)).Range.Text
Next i
To all intents and purposes, this works. Problem is, it's feasible for some
bookmarks to be blank and when they are, the userform is pulling in a
paragraph mark or a space (because that's whats currently inside the bookmark
I guess).
It's doing what I tell it to do but this isn't what I want (typical woman,
huh?) - is there any other way I can pull in just the text from inside the
bookmark?
Because the doc is designed to work to the specifications of the program
it's going to be imported into, I can't get rid of the carriage returns in
the doc, which is structured something like this:
###AgencyRef1
[bookmark]
#Price1
[bookmark]
....etc
Also....
Submitting the edited details by clicking the command button is appending
the value of the controls to what is already in each bookmark - which is,
again, no good. I could clear all the bookmarks before entering the values in
them, but as the user is only going to be editing the userform contents this
may lead me to wipe out information that is actually needed.
This is an example of the type of thing I have coded onto the command
button, just in case you can see any rookie errors or 'stupid thinking':
For i = 1 To 48
ActiveDocument.Bookmarks("bmkAgencyRef" & CStr(i)).Range _
..InsertBefore Me.Controls("txtAgencyRef" & CStr(i)).Text
Next i
Can anyone think of a way round this? Am I a hopeless case? Shall I just
give up and tell the user to "Do it your @~#! self!" ? Anyone shedding any
light is welcome to my firstborn.