Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Bookmark Dilemma

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Office_Novice - 04 Jan 2008 03:04 GMT
Greetings, Iwould like to know if there is a way to Clear the contents
between two bookmarks populated from a userForm after the document is
finished and printed.

I am using 10 userforms to populate diffrent fields in a document. I would
like it to "Reset" the fields after it has been printed.  Is this possible in
word?
Doug Robbins - Word MVP - 04 Jan 2008 05:20 GMT
I am not sure why you would be using 10 userforms to populate different
fields in a document.

Exactly what do you mean by "fields"?  Are they ordinary bookmarks or are
they formfields (as used in a document that is protected for forms)?

Also, is it really the text "between two bookmarks" that you want to clear,
or is it the text in the bookmarks?

I realise that all I have done is ask you questions rather than giving you
an answer, but it will be best if you tell us exactly what it is that you
are doing and also the work process involved, as by doing that, we can give
you the best method to accomplish the task.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Greetings, Iwould like to know if there is a way to Clear the contents
> between two bookmarks populated from a userForm after the document is
[quoted text clipped - 4 lines]
> in
> word?
Office_Novice - 04 Jan 2008 16:14 GMT
I have a form letter that I am using UserForms to populate the variables. I
have used a table to control document flow and hold the consents. I am using
With ActiveDocument
   .Bookmarks("Text1").Range _
   .InsertBefore TextBox1
   .Bookmarks("Text2").Range _
   .InsertBefore TextBox2
End With

UserForm1.Hide

To hold the variable information that needs to be added.  I would like the
variable information to clear itself from the form letter so it is ready to
use next time. Or maybe overwrite the information previously added, either
works for me. I know this can be done in excel but can it be done in word? If
so, how? Or shoul i just use Excel?

> I am not sure why you would be using 10 userforms to populate different
> fields in a document.
[quoted text clipped - 18 lines]
> > in
> > word?
fumei - 04 Jan 2008 19:25 GMT
"I would like the variable information to clear itself from the form letter
so it is ready to use next time."

This seems to me, if I understand correctly, to call for using a template.
Doug Robbins - Word MVP - 06 Jan 2008 08:18 GMT
Rather that mess around with bookmarks, it would be better to use
Docvariable fields and document variables

With ActiveDocument
   .Variables("Text1").Value = TextBox1
   .Variables("Text2").Value = TextBox2
   'etc.
   .Range.Fields.Update
End With

Then in the template have docvariable fields where you want the information
to appear, viz

{ DOCVARIABLE Text1 }

{ DOCVARIABLE Text2 }

I would suggest however that in place of Text1, Text2 and TextBox1 and
TextBox2, you use names that relate to the content of the control/variable.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I have a form letter that I am using UserForms to populate the variables. I
> have used a table to control document flow and hold the consents. I am
[quoted text clipped - 43 lines]
>> > in
>> > word?
Aubrey - 09 Jan 2008 05:52 GMT
I am trying to reply to the newsgroup.  If I didn't, it was in error.  I
used your docvariable fields suggestion in my own form letter.  It worked
well when I ran small test form letter, but when I applied it to my final
form letter, the "info" never shows up.  Could this be because I have all
the docvariables in the header?  Does this require different coding?  Thank
you for any advise in advance.  Aubrey

> Rather that mess around with bookmarks, it would be better to use
> Docvariable fields and document variables
[quoted text clipped - 69 lines]
>>> > in
>>> > word?
Doug Robbins - Word MVP - 09 Jan 2008 09:58 GMT
You will either need to use code that accesses the fields in the header
range, or take the easy way and use

With ActiveDocument
   .PrintPreview
   .ClosePrintPreview
End With

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I am trying to reply to the newsgroup.  If I didn't, it was in error.  I
> used your docvariable fields suggestion in my own form letter.  It worked
[quoted text clipped - 78 lines]
>>>> > in
>>>> > word?
Office_Novice - 09 Jan 2008 13:34 GMT
I too used your {Docvariable} Suggestion, works great! However it did bring
up an interesting question, Can I use {DocVariable} for a variable that only
occurs sometimes? i.e. "your name here" as a {docVarialbe} that will happen
all the time
"Your Spouse's Name here” as a {docVariable} which may not occur all the time.
So my question If the user leaves the textbox blank is there a way to remove
or hide the {docvariable} to preserve the standard letter format. I tried
some things like this…

Private Sub CommandButton3_Click()
With ActiveDocument
If Me.TextBox11.Value = "" Then
.Variables("Text15").Value = ""
End If

“ It didn’t work”  Thanks for your help you MVPs are life savers.
=====================================================

> You will either need to use code that accesses the fields in the header
> range, or take the easy way and use
[quoted text clipped - 86 lines]
> >>>> > in
> >>>> > word?
Doug Robbins - Word MVP - 09 Jan 2008 20:01 GMT
The best way to handle this would depend on how you want the information to
appear in the letter (with and without the spouse).

Tell us more about it.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I too used your {Docvariable} Suggestion, works great! However it did bring
> up an interesting question, Can I use {DocVariable} for a variable that
[quoted text clipped - 122 lines]
>> >>>> > in
>> >>>> > word?
Office_Novice - 09 Jan 2008 21:21 GMT
Pretty basic stuff... but i am new to this.

"Name Here"
"Next Name Here"
"Somtimes Here"
Address here
City here, St, zip code.

> The best way to handle this would depend on how you want the information to
> appear in the letter (with and without the spouse).
[quoted text clipped - 127 lines]
> >> >>>> > in
> >> >>>> > word?
Doug Robbins - Word MVP - 11 Jan 2008 01:44 GMT
I would create a string from the information entered into the user form and
then set the value of the document variable to that string

For example

Dim strname as String
strname = ""
strname = txtNameHere & vbCr txtNextNameHere
If txtSometimesHere <> "" then
      strName = strname & vbCr & txtSometimesHere
End If
ActiveDocument.Variables("varname").Value = strname

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Pretty basic stuff... but i am new to this.
>
[quoted text clipped - 153 lines]
>> >> >>>> > in
>> >> >>>> > word?
Office_Novice - 11 Jan 2008 14:01 GMT
I will Try That Thanks.

I swear it never ends with this thing!

Is there a way to programaticly tell Word to send it to a specific printer
and choose a paper source? I need this letter to be printed on letter head
but it keeps printing from the wrong source. i.e tray 1 when i need to feed
it manually. any ideas?

> I would create a string from the information entered into the user form and
> then set the value of the document variable to that string
[quoted text clipped - 166 lines]
> >> >> >>>> > in
> >> >> >>>> > word?
Doug Robbins - Word MVP - 11 Jan 2008 20:15 GMT
In the Page Setup dialog under the "Paper" tab, you can specify the source
of the paper.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I will Try That Thanks.
>
[quoted text clipped - 195 lines]
>> >> >> >>>> > in
>> >> >> >>>> > word?
Office_Novice - 13 Jan 2008 02:39 GMT
I tried that to no avail. any other thoughts?

> In the Page Setup dialog under the "Paper" tab, you can specify the source
> of the paper.
[quoted text clipped - 198 lines]
> >> >> >> >>>> > in
> >> >> >> >>>> > word?
Aubrey - 09 Jan 2008 18:58 GMT
Works great, except my screen is "small" when it comes back.  I tried this
line of code after yours to make large again, but didn't work ... any
suggestions?

.PrintPreview
.ClosePrintPreview
Application.WindowState = wdWindowStateMaximize

> You will either need to use code that accesses the fields in the header
> range, or take the easy way and use
[quoted text clipped - 88 lines]
>>>>> > in
>>>>> > word?
Doug Robbins - Word MVP - 09 Jan 2008 20:06 GMT
That should not be happening.

You may have to use

ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Fields.Update

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Works great, except my screen is "small" when it comes back.  I tried this
> line of code after yours to make large again, but didn't work ... any
[quoted text clipped - 99 lines]
>>>>>> > in
>>>>>> > word?
Aubrey - 14 Jan 2008 04:33 GMT
This code is working great so far!!  I created an a "form letter" with an
envelope at the top to print out with letter, but I found when I put it at
the top of the letter, my Page X of Y on the form letter counted the
envelope as a page.  Can the mergefield be made to do Page X of (Y-1)?

I removed the envelope and put it in it own file to avoid the page count
problem, but it isn't working smoothly.  The wrong window is always active
when trying the print the envelopes from the form letter userform.

> That should not be happening.
>
[quoted text clipped - 105 lines]
>>>>>>> > in
>>>>>>> > word?
Doug Robbins - Word MVP - 14 Jan 2008 11:31 GMT
You could use a SectionPages field in place of the NumPages field or use a
formula { = { numpages } - 1 }

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> This code is working great so far!!  I created an a "form letter" with an
> envelope at the top to print out with letter, but I found when I put it at
[quoted text clipped - 116 lines]
>>>>>>>> > in
>>>>>>>> > word?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.