Report Field Data Insertion & Update 
Author Message
 Report Field Data Insertion & Update

I am just learning VBA for WORD, and am doing a project for a large Report
template.

I want to enter the title and edition number on the front page, and then have
these inserted at relevant points in the body text, and in the footers,throughout
the document.

Also, if the user later changes the title or edition number on the first page, he
wants this information updated where it's been inserted in the text and footers
throughout the document.

I've tried several things:-

1  styleref fields don't seem to cross section breaks, and I've got a number of
section breaks in the document

2  ref fields linked to bookmarks don't achieve the desired result because of the
in-built paragraph mark, with gives me an unwanted carriage return when the data
is inserted in the document

3  I thought of putting the contents of the Title and Edition Number ookmarks
into a couple of custom doc properties that I'd added   to the template, but I
can't get the macro to input the bookmarks contents into these properties.

I'm sure that someone more experienced than me can tell me an easy way to do
this, it must be a standard  requirement in almost all report templates.

I can check the forum for replies, or you could e-mail me if you prefer at

Thanks for any help you can give me...Dave



Wed, 29 Oct 2003 03:33:18 GMT  
 Report Field Data Insertion & Update
Hi, Dave,

Ref fields and bookmarks should work just fine. There is no "in-built
paragraph mark" in these things -- if your ref fields show a paragraph mark,
it's because you've accidentally included a paragraph mark inside the
bookmark.

Go to Tools/Options/View and turn on the display of bookmarks. They'll look
like big black square brackets (unless the bookmark is collapsed to a point,
so the brackets overlap and look like an I). Also turn on paragraph marks.
If there's a paragraph mark inside the bookmark, highlight just the text and
then re-insert the bookmark, so it will exclude the paragraph mark.

If you're inserting the bookmark's contents through a macro, avoid including
a vbCr in the string. See
http://www.mvps.org/word/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for more
tips.

Regards,
Jay


Quote:
>I am just learning VBA for WORD, and am doing a project for a large Report
>template.

>I want to enter the title and edition number on the front page, and then
have
>these inserted at relevant points in the body text, and in the
footers,throughout
>the document.

>Also, if the user later changes the title or edition number on the first
page, he
>wants this information updated where it's been inserted in the text and
footers
>throughout the document.

>I've tried several things:-

>1  styleref fields don't seem to cross section breaks, and I've got a
number of
>section breaks in the document

>2  ref fields linked to bookmarks don't achieve the desired result because
of the
>in-built paragraph mark, with gives me an unwanted carriage return when the
data
>is inserted in the document

>3  I thought of putting the contents of the Title and Edition Number
ookmarks
>into a couple of custom doc properties that I'd added to the template, but
I
>can't get the macro to input the bookmarks contents into these properties.

>I'm sure that someone more experienced than me can tell me an easy way to
do
>this, it must be a standard  requirement in almost all report templates.

>I can check the forum for replies, or you could e-mail me if you prefer at

>Thanks for any help you can give me...Dave



Wed, 29 Oct 2003 03:56:01 GMT  
 Report Field Data Insertion & Update
Hi Jay - thanks very much for your quick response to my query about ref fields
and bookmarks.

I've actually tried what you said - take the paragraph marks out of the
bookmarks - but this doesn't seem to work.

If I include text or a space in the bookmarks so they're not collapsed, the ref
fields then give me an error message of "Ref not found", because when I insert
the data from the macro userform into the bookmark (I'm using a
selection.typetext instruction), it actually deletes the bookmark!

On the other hand, if I just have a collapsed bookmark, then the ref fields don't
pick up anything at all.  

I have read somewhere in one of the manuals that you have to include a paragraph
mark for ref fields to work, that's what I meant by the "in-built" paragraph mark
in my original query.

Am I misunderstanding this somehow? I reckon I must be missing something simple
here.

Your help is much appreciated - I've spent days cursing this and getting
nowhere.I'm inserting the bookmark into the template in word, not through a macro.


Dave

Quote:
-----Original Message-----
Hi, Dave,

Ref fields and bookmarks should work just fine. There is no "in-built
paragraph mark" in these things -- if your ref fields show a paragraph mark,
it's because you've accidentally included a paragraph mark inside the
bookmark.

Go to Tools/Options/View and turn on the display of bookmarks. They'll look
like big black square brackets (unless the bookmark is collapsed to a point,
so the brackets overlap and look like an I). Also turn on paragraph marks.
If there's a paragraph mark inside the bookmark, highlight just the text and
then re-insert the bookmark, so it will exclude the paragraph mark.

If you're inserting the bookmark's contents through a macro, avoid including
a vbCr in the string. See
http://www.mvps.org/word/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for more
tips.

Regards,
Jay



>I am just learning VBA for WORD, and am doing a project for a large Report
>template.

>I want to enter the title and edition number on the front page, and then
have
>these inserted at relevant points in the body text, and in the
footers,throughout
>the document.

>Also, if the user later changes the title or edition number on the first
page, he
>wants this information updated where it's been inserted in the text and
footers
>throughout the document.

>I've tried several things:-

>1  styleref fields don't seem to cross section breaks, and I've got a
number of
>section breaks in the document

>2  ref fields linked to bookmarks don't achieve the desired result because
of the
>in-built paragraph mark, with gives me an unwanted carriage return when the
data
>is inserted in the document

>3  I thought of putting the contents of the Title and Edition Number
ookmarks
>into a couple of custom doc properties that I'd added to the template, but
I
>can't get the macro to input the bookmarks contents into these properties.

>I'm sure that someone more experienced than me can tell me an easy way to
do
>this, it must be a standard  requirement in almost all report templates.

>I can check the forum for replies, or you could e-mail me if you prefer at

>Thanks for any help you can give me...Dave

.



Wed, 29 Oct 2003 17:10:51 GMT  
 Report Field Data Insertion & Update

David,

This'll probably help:

http://www.mvps.org/word/FAQs/MacrosVBA/InsertingTextAtBookmark.htm

You may also find benefit (though not necessarily now in this project)
in using ranges to insert text from your user form, rather than doing
it with Selection.TypeText:

ActiveDocument.Bookmarks("foo").Range.InsertAfter TextBox4.Text


------ WWW: http://www.speakeasy.org/~mtangard ----------------------
------------- "Life is nothing if you aren't obsessed." --John Waters
---------------------------------------------------------------------

Quote:

> Hi Jay - thanks very much for your quick response to my query about ref fields
> and bookmarks.

> I've actually tried what you said - take the paragraph marks out of the
> bookmarks - but this doesn't seem to work.

> If I include text or a space in the bookmarks so they're not collapsed, the ref
> fields then give me an error message of "Ref not found", because when I insert
> the data from the macro userform into the bookmark (I'm using a
> selection.typetext instruction), it actually deletes the bookmark!

> On the other hand, if I just have a collapsed bookmark, then the ref fields don't
> pick up anything at all.

> I have read somewhere in one of the manuals that you have to include a paragraph
> mark for ref fields to work, that's what I meant by the "in-built" paragraph mark
> in my original query.

> Am I misunderstanding this somehow? I reckon I must be missing something simple
> here.

> Your help is much appreciated - I've spent days cursing this and getting
> nowhere.I'm inserting the bookmark into the template in word, not through a macro.


> Dave
> -----Original Message-----
> Hi, Dave,

> Ref fields and bookmarks should work just fine. There is no "in-built
> paragraph mark" in these things -- if your ref fields show a paragraph mark,
> it's because you've accidentally included a paragraph mark inside the
> bookmark.

> Go to Tools/Options/View and turn on the display of bookmarks. They'll look
> like big black square brackets (unless the bookmark is collapsed to a point,
> so the brackets overlap and look like an I). Also turn on paragraph marks.
> If there's a paragraph mark inside the bookmark, highlight just the text and
> then re-insert the bookmark, so it will exclude the paragraph mark.

> If you're inserting the bookmark's contents through a macro, avoid including
> a vbCr in the string. See
> http://www.mvps.org/word/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for more
> tips.

> Regards,
> Jay



> >I am just learning VBA for WORD, and am doing a project for a large Report
> >template.

> >I want to enter the title and edition number on the front page, and then
> have
> >these inserted at relevant points in the body text, and in the
> footers,throughout
> >the document.

> >Also, if the user later changes the title or edition number on the first
> page, he
> >wants this information updated where it's been inserted in the text and
> footers
> >throughout the document.

> >I've tried several things:-

> >1  styleref fields don't seem to cross section breaks, and I've got a
> number of
> >section breaks in the document

> >2  ref fields linked to bookmarks don't achieve the desired result because
> of the
> >in-built paragraph mark, with gives me an unwanted carriage return when the
> data
> >is inserted in the document

> >3  I thought of putting the contents of the Title and Edition Number
> ookmarks
> >into a couple of custom doc properties that I'd added to the template, but
> I
> >can't get the macro to input the bookmarks contents into these properties.

> >I'm sure that someone more experienced than me can tell me an easy way to
> do
> >this, it must be a standard  requirement in almost all report templates.

> >I can check the forum for replies, or you could e-mail me if you prefer at

> >Thanks for any help you can give me...Dave

> .



Wed, 29 Oct 2003 18:12:44 GMT  
 Report Field Data Insertion & Update
Mark,

Thanks for stepping in... I'm a little slow getting online on Saturday
mornings, preferring to sleep in. <g> That's the same response I would have
given.

David,
You noticed that replacing the contents of a noncollapsed bookmark deletes
the bookmark. In the other case, inserting text at a collapsed bookmark,
Word actually inserts the text *outside* the bookmark, leaving the bookmark
still collapsed. That's why the ref field doesn't show a result.

As the FAQS article says, in either case, the solution is to reassign the
bookmark with the .Add method after inserting new content. (I consider this
a bug with an ugly workaround, and I wonder how many billions of CPU cycles
have been wasted by it... but it's unlikely ever to change.)

Whether or not there's a paragraph mark inside the bookmark has no bearing
on getting the ref fields to work; having one there only ensures that the
ref field *will* display a paragraph mark.

Regards,
Jay


Quote:

> David,

> This'll probably help:

> http://www.mvps.org/word/FAQs/MacrosVBA/InsertingTextAtBookmark.htm

> You may also find benefit (though not necessarily now in this project)
> in using ranges to insert text from your user form, rather than doing
> it with Selection.TypeText:

> ActiveDocument.Bookmarks("foo").Range.InsertAfter TextBox4.Text


> ------ WWW: http://www.speakeasy.org/~mtangard ----------------------
> ------------- "Life is nothing if you aren't obsessed." --John Waters
> ---------------------------------------------------------------------


> > Hi Jay - thanks very much for your quick response to my query about ref
fields
> > and bookmarks.

> > I've actually tried what you said - take the paragraph marks out of the
> > bookmarks - but this doesn't seem to work.

> > If I include text or a space in the bookmarks so they're not collapsed,
the ref
> > fields then give me an error message of "Ref not found", because when I
insert
> > the data from the macro userform into the bookmark (I'm using a
> > selection.typetext instruction), it actually deletes the bookmark!

> > On the other hand, if I just have a collapsed bookmark, then the ref
fields don't
> > pick up anything at all.

> > I have read somewhere in one of the manuals that you have to include a
paragraph
> > mark for ref fields to work, that's what I meant by the "in-built"
paragraph mark
> > in my original query.

> > Am I misunderstanding this somehow? I reckon I must be missing something
simple
> > here.

> > Your help is much appreciated - I've spent days cursing this and getting
> > nowhere.I'm inserting the bookmark into the template in word, not
through a macro.


> > Dave
> > -----Original Message-----
> > Hi, Dave,

> > Ref fields and bookmarks should work just fine. There is no "in-built
> > paragraph mark" in these things -- if your ref fields show a paragraph
mark,
> > it's because you've accidentally included a paragraph mark inside the
> > bookmark.

> > Go to Tools/Options/View and turn on the display of bookmarks. They'll
look
> > like big black square brackets (unless the bookmark is collapsed to a
point,
> > so the brackets overlap and look like an I). Also turn on paragraph
marks.
> > If there's a paragraph mark inside the bookmark, highlight just the text
and
> > then re-insert the bookmark, so it will exclude the paragraph mark.

> > If you're inserting the bookmark's contents through a macro, avoid
including
> > a vbCr in the string. See
> > http://www.mvps.org/word/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for
more
> > tips.

> > Regards,
> > Jay



> > >I am just learning VBA for WORD, and am doing a project for a large
Report
> > >template.

> > >I want to enter the title and edition number on the front page, and
then
> > have
> > >these inserted at relevant points in the body text, and in the
> > footers,throughout
> > >the document.

> > >Also, if the user later changes the title or edition number on the
first
> > page, he
> > >wants this information updated where it's been inserted in the text and
> > footers
> > >throughout the document.

> > >I've tried several things:-

> > >1  styleref fields don't seem to cross section breaks, and I've got a
> > number of
> > >section breaks in the document

> > >2  ref fields linked to bookmarks don't achieve the desired result
because
> > of the
> > >in-built paragraph mark, with gives me an unwanted carriage return when
the
> > data
> > >is inserted in the document

> > >3  I thought of putting the contents of the Title and Edition Number
> > ookmarks
> > >into a couple of custom doc properties that I'd added to the template,
but
> > I
> > >can't get the macro to input the bookmarks contents into these
properties.

> > >I'm sure that someone more experienced than me can tell me an easy way
to
> > do
> > >this, it must be a standard  requirement in almost all report
templates.

> > >I can check the forum for replies, or you could e-mail me if you prefer
at

> > >Thanks for any help you can give me...Dave

> > .



Wed, 29 Oct 2003 23:33:20 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Report Fields Data Insertion and Update

2. Generic insertion combo box (was :Insert text at Insertion point of a field)

3. Crystal Reports Updating Data Fields

4. Updating data to a memo field using SQL UPDATE

5. Use report fields to update table fields

6. Update a Bound field with data from unbound field

7. VB6 Data Environment & Data Report

8. help w/ data evironment & data reports

9. Data Report & ADO Data Control

10. MTS & VB6 Data Report and Data Environment

11. AddNew/Update command & field searches

12. UPDATE STATEMENT TIME INSERTION

 

 
Powered by phpBB® Forum Software