Hello,

Here is my problem: I have an Access table with 2 columns: a keyword
and a memo. From this table I want to create a Word document - this is
no brainer, I know how to do it. Now the difficult part - I want to
create an index table from the keyword columns (or table of containts).
My question: what are the internal values of code that mark a word an
the index?
I know how to do it manualy, but because the table have over thousand
entries, I want to do it automaticly.

Thanks,

Zalek

Re: internal code for index or table of contents by Jonathan

Jonathan
Sun Jul 31 06:57:56 CDT 2005

First question. Do you want a Table of Contents (i.e. with the entries in
the table in the order in thich they appear in the document) or an Index
(i.e. with the entries sorted alphabetically?

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

"zalek" <zalekbloom@hotmail.com> wrote in message
news:1122809866.433829.249290@g49g2000cwa.googlegroups.com...
> Hello,
>
> Here is my problem: I have an Access table with 2 columns: a keyword
> and a memo. From this table I want to create a Word document - this is
> no brainer, I know how to do it. Now the difficult part - I want to
> create an index table from the keyword columns (or table of containts).
> My question: what are the internal values of code that mark a word an
> the index?
> I know how to do it manualy, but because the table have over thousand
> entries, I want to do it automaticly.
>
> Thanks,
>
> Zalek
>


Re: internal code for index or table of contents by zalek

zalek
Sun Jul 31 10:19:24 CDT 2005


Jonathan West wrote:
> First question. Do you want a Table of Contents (i.e. with the entries in
> the table in the order in thich they appear in the document) or an Index
> (i.e. with the entries sorted alphabetically?
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup


I prefare the Index, but I would like to know codes for the Table of
Contents too.

Thanks,

Zalek


> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>
> "zalek" <zalekbloom@hotmail.com> wrote in message
> news:1122809866.433829.249290@g49g2000cwa.googlegroups.com...
> > Hello,
> >
> > Here is my problem: I have an Access table with 2 columns: a keyword
> > and a memo. From this table I want to create a Word document - this is
> > no brainer, I know how to do it. Now the difficult part - I want to
> > create an index table from the keyword columns (or table of containts).
> > My question: what are the internal values of code that mark a word an
> > the index?
> > I know how to do it manualy, but because the table have over thousand
> > entries, I want to do it automaticly.
> >
> > Thanks,
> >
> > Zalek
> >


Re: internal code for index or table of contents by Suzanne

Suzanne
Sun Jul 31 12:26:20 CDT 2005

XE fields are used to create an index, TC fields a TOC. You can create a TOC
without using TC fields (using headings or outline levels), but you cannot
create an index except with XE fields. See the Help topic "Field codes: XE
(Index Entry) field" for more.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"zalek" <zalekbloom@hotmail.com> wrote in message
news:1122823164.715491.104460@g43g2000cwa.googlegroups.com...
>
> Jonathan West wrote:
> > First question. Do you want a Table of Contents (i.e. with the entries
in
> > the table in the order in thich they appear in the document) or an Index
> > (i.e. with the entries sorted alphabetically?
> >
> > --
> > Regards
> > Jonathan West - Word MVP
> > www.intelligentdocuments.co.uk
> > Please reply to the newsgroup
>
>
> I prefare the Index, but I would like to know codes for the Table of
> Contents too.
>
> Thanks,
>
> Zalek
>
>
> > Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
> >
> > "zalek" <zalekbloom@hotmail.com> wrote in message
> > news:1122809866.433829.249290@g49g2000cwa.googlegroups.com...
> > > Hello,
> > >
> > > Here is my problem: I have an Access table with 2 columns: a keyword
> > > and a memo. From this table I want to create a Word document - this is
> > > no brainer, I know how to do it. Now the difficult part - I want to
> > > create an index table from the keyword columns (or table of
containts).
> > > My question: what are the internal values of code that mark a word an
> > > the index?
> > > I know how to do it manualy, but because the table have over thousand
> > > entries, I want to do it automaticly.
> > >
> > > Thanks,
> > >
> > > Zalek
> > >
>


Re: internal code for index or table of contents by Jonathan

Jonathan
Sun Jul 31 13:02:20 CDT 2005

If you want to add the field by means of a VBA macro, then you use the Add
method of the Fields collection. The Range property of the method defines
where the field is inserted. You can insert XE and TC fields this way.

The VBA help file entry for the Fields collection includes code examples for
how to do this.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

"Suzanne S. Barnhill" <sbarnhill@mvps.org> wrote in message
news:OecY6YflFHA.4028@TK2MSFTNGP10.phx.gbl...
> XE fields are used to create an index, TC fields a TOC. You can create a
> TOC
> without using TC fields (using headings or outline levels), but you cannot
> create an index except with XE fields. See the Help topic "Field codes: XE
> (Index Entry) field" for more.
>
> --
> Suzanne S. Barnhill
> Microsoft MVP (Word)
> Words into Type
> Fairhope, Alabama USA
> Word MVP FAQ site: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup
> so
> all may benefit.
>
> "zalek" <zalekbloom@hotmail.com> wrote in message
> news:1122823164.715491.104460@g43g2000cwa.googlegroups.com...
>>
>> Jonathan West wrote:
>> > First question. Do you want a Table of Contents (i.e. with the entries
> in
>> > the table in the order in thich they appear in the document) or an
>> > Index
>> > (i.e. with the entries sorted alphabetically?
>> >
>> > --
>> > Regards
>> > Jonathan West - Word MVP
>> > www.intelligentdocuments.co.uk
>> > Please reply to the newsgroup
>>
>>
>> I prefare the Index, but I would like to know codes for the Table of
>> Contents too.
>>
>> Thanks,
>>
>> Zalek
>>
>>
>> > Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>> >
>> > "zalek" <zalekbloom@hotmail.com> wrote in message
>> > news:1122809866.433829.249290@g49g2000cwa.googlegroups.com...
>> > > Hello,
>> > >
>> > > Here is my problem: I have an Access table with 2 columns: a keyword
>> > > and a memo. From this table I want to create a Word document - this
>> > > is
>> > > no brainer, I know how to do it. Now the difficult part - I want to
>> > > create an index table from the keyword columns (or table of
> containts).
>> > > My question: what are the internal values of code that mark a word an
>> > > the index?
>> > > I know how to do it manualy, but because the table have over thousand
>> > > entries, I want to do it automaticly.
>> > >
>> > > Thanks,
>> > >
>> > > Zalek
>> > >
>>
>


Re: internal code for index or table of contents by zalek

zalek
Mon Aug 01 18:07:39 CDT 2005

Well, I tried to do it, but it didn't work.

Here is what I did:

I wrote the Access table to a .TXT file.
For each string I wanted to be in the Index I created a additional
string '{XE "field name" }', for example if I wanted the string Zalek
to be in the Index - I wroted:
Zalek {XE "Zalek"}
Next opened the created .txt file in the Word. but when I tried: Insert
- Indexes and tables it said:
Error! No index entries found.

I also looked on values of inserted string when I created the Index
from the Word. It showed that the Word insted of character { is using a
character of ACII value 19 and insted of charater } is using a charater
of ascii value 21.

Any ideas what to do next?

Thanks,

Zalek

Jonathan West wrote:
> If you want to add the field by means of a VBA macro, then you use the Add
> method of the Fields collection. The Range property of the method defines
> where the field is inserted. You can insert XE and TC fields this way.
>
> The VBA help file entry for the Fields collection includes code examples for
> how to do this.
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>
> "Suzanne S. Barnhill" <sbarnhill@mvps.org> wrote in message
> news:OecY6YflFHA.4028@TK2MSFTNGP10.phx.gbl...
> > XE fields are used to create an index, TC fields a TOC. You can create a
> > TOC
> > without using TC fields (using headings or outline levels), but you cannot
> > create an index except with XE fields. See the Help topic "Field codes: XE
> > (Index Entry) field" for more.
> >
> > --
> > Suzanne S. Barnhill
> > Microsoft MVP (Word)
> > Words into Type
> > Fairhope, Alabama USA
> > Word MVP FAQ site: http://word.mvps.org
> > Email cannot be acknowledged; please post all follow-ups to the newsgroup
> > so
> > all may benefit.
> >
> > "zalek" <zalekbloom@hotmail.com> wrote in message
> > news:1122823164.715491.104460@g43g2000cwa.googlegroups.com...
> >>
> >> Jonathan West wrote:
> >> > First question. Do you want a Table of Contents (i.e. with the entries
> > in
> >> > the table in the order in thich they appear in the document) or an
> >> > Index
> >> > (i.e. with the entries sorted alphabetically?
> >> >
> >> > --
> >> > Regards
> >> > Jonathan West - Word MVP
> >> > www.intelligentdocuments.co.uk
> >> > Please reply to the newsgroup
> >>
> >>
> >> I prefare the Index, but I would like to know codes for the Table of
> >> Contents too.
> >>
> >> Thanks,
> >>
> >> Zalek
> >>
> >>
> >> > Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
> >> >
> >> > "zalek" <zalekbloom@hotmail.com> wrote in message
> >> > news:1122809866.433829.249290@g49g2000cwa.googlegroups.com...
> >> > > Hello,
> >> > >
> >> > > Here is my problem: I have an Access table with 2 columns: a keyword
> >> > > and a memo. From this table I want to create a Word document - this
> >> > > is
> >> > > no brainer, I know how to do it. Now the difficult part - I want to
> >> > > create an index table from the keyword columns (or table of
> > containts).
> >> > > My question: what are the internal values of code that mark a word an
> >> > > the index?
> >> > > I know how to do it manualy, but because the table have over thousand
> >> > > entries, I want to do it automaticly.
> >> > >
> >> > > Thanks,
> >> > >
> >> > > Zalek
> >> > >
> >>
> >


Re: internal code for index or table of contents by Jonathan

Jonathan
Mon Aug 01 19:21:02 CDT 2005

zalek,

Field are not just strings. Specifically, the {} field code delimiters are
*not* curly brace characters, though they look very much like them.

If you want to insert these fields using VBA you *must* use the Add method
of the Fields collection. Look it up in the VBA help.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org


"zalek" <zalekbloom@hotmail.com> wrote in message
news:1122937659.805762.32140@g47g2000cwa.googlegroups.com...
> Well, I tried to do it, but it didn't work.
>
> Here is what I did:
>
> I wrote the Access table to a .TXT file.
> For each string I wanted to be in the Index I created a additional
> string '{XE "field name" }', for example if I wanted the string Zalek
> to be in the Index - I wroted:
> Zalek {XE "Zalek"}
> Next opened the created .txt file in the Word. but when I tried: Insert
> - Indexes and tables it said:
> Error! No index entries found.
>
> I also looked on values of inserted string when I created the Index
> from the Word. It showed that the Word insted of character { is using a
> character of ACII value 19 and insted of charater } is using a charater
> of ascii value 21.
>
> Any ideas what to do next?
>
> Thanks,
>
> Zalek
>
> Jonathan West wrote:
>> If you want to add the field by means of a VBA macro, then you use the
>> Add
>> method of the Fields collection. The Range property of the method defines
>> where the field is inserted. You can insert XE and TC fields this way.
>>
>> The VBA help file entry for the Fields collection includes code examples
>> for
>> how to do this.
>>
>> --
>> Regards
>> Jonathan West - Word MVP
>> www.intelligentdocuments.co.uk
>> Please reply to the newsgroup
>> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>>
>> "Suzanne S. Barnhill" <sbarnhill@mvps.org> wrote in message
>> news:OecY6YflFHA.4028@TK2MSFTNGP10.phx.gbl...
>> > XE fields are used to create an index, TC fields a TOC. You can create
>> > a
>> > TOC
>> > without using TC fields (using headings or outline levels), but you
>> > cannot
>> > create an index except with XE fields. See the Help topic "Field codes:
>> > XE
>> > (Index Entry) field" for more.
>> >
>> > --
>> > Suzanne S. Barnhill
>> > Microsoft MVP (Word)
>> > Words into Type
>> > Fairhope, Alabama USA
>> > Word MVP FAQ site: http://word.mvps.org
>> > Email cannot be acknowledged; please post all follow-ups to the
>> > newsgroup
>> > so
>> > all may benefit.
>> >
>> > "zalek" <zalekbloom@hotmail.com> wrote in message
>> > news:1122823164.715491.104460@g43g2000cwa.googlegroups.com...
>> >>
>> >> Jonathan West wrote:
>> >> > First question. Do you want a Table of Contents (i.e. with the
>> >> > entries
>> > in
>> >> > the table in the order in thich they appear in the document) or an
>> >> > Index
>> >> > (i.e. with the entries sorted alphabetically?
>> >> >
>> >> > --
>> >> > Regards
>> >> > Jonathan West - Word MVP
>> >> > www.intelligentdocuments.co.uk
>> >> > Please reply to the newsgroup
>> >>
>> >>
>> >> I prefare the Index, but I would like to know codes for the Table of
>> >> Contents too.
>> >>
>> >> Thanks,
>> >>
>> >> Zalek
>> >>
>> >>
>> >> > Keep your VBA code safe, sign the ClassicVB petition
>> >> > www.classicvb.org
>> >> >
>> >> > "zalek" <zalekbloom@hotmail.com> wrote in message
>> >> > news:1122809866.433829.249290@g49g2000cwa.googlegroups.com...
>> >> > > Hello,
>> >> > >
>> >> > > Here is my problem: I have an Access table with 2 columns: a
>> >> > > keyword
>> >> > > and a memo. From this table I want to create a Word document -
>> >> > > this
>> >> > > is
>> >> > > no brainer, I know how to do it. Now the difficult part - I want
>> >> > > to
>> >> > > create an index table from the keyword columns (or table of
>> > containts).
>> >> > > My question: what are the internal values of code that mark a word
>> >> > > an
>> >> > > the index?
>> >> > > I know how to do it manualy, but because the table have over
>> >> > > thousand
>> >> > > entries, I want to do it automaticly.
>> >> > >
>> >> > > Thanks,
>> >> > >
>> >> > > Zalek
>> >> > >
>> >>
>> >
>


Re: internal code for index or table of contents by zalek

zalek
Wed Aug 03 18:50:50 CDT 2005

Jonathan,

I really appreciate your time - thanks for answering.

Let me bug you a little more.
I already order a few books on VBA, but meantime:
I have a .txt file with text and list of words I want to appear in the
Index, based on the text in my .txt file.

My question:

1. What is a field object?
I made a test - created a word document with a few words and created a
macro:

Sub VBAtest1()
Dim oField As Field
Dim i As Integer
Open "c:\vab-test.txt" For Output As #1
i = ActiveDocument.Fields.Count
Write #1, i
Close #1

End Sub

File shows zero. So what is a Field in the document?

2. Let say in my document each field I want to index I'll write with
prefix @@, for example if I'll want to index the word "Zalek" - I will
write it as "@@Zalek".
What are VBA commands that will let me scan all words in the document
and test if they have prefix "@@"?

Thanks again,

Zalek



Jonathan West wrote:
> zalek,
>
> Field are not just strings. Specifically, the {} field code delimiters are
> *not* curly brace characters, though they look very much like them.
>
> If you want to insert these fields using VBA you *must* use the Add method
> of the Fields collection. Look it up in the VBA help.
>
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>
>
> "zalek" <zalekbloom@hotmail.com> wrote in message
> news:1122937659.805762.32140@g47g2000cwa.googlegroups.com...
> > Well, I tried to do it, but it didn't work.
> >
> > Here is what I did:
> >
> > I wrote the Access table to a .TXT file.
> > For each string I wanted to be in the Index I created a additional
> > string '{XE "field name" }', for example if I wanted the string Zalek
> > to be in the Index - I wroted:
> > Zalek {XE "Zalek"}
> > Next opened the created .txt file in the Word. but when I tried: Insert
> > - Indexes and tables it said:
> > Error! No index entries found.
> >
> > I also looked on values of inserted string when I created the Index
> > from the Word. It showed that the Word insted of character { is using a
> > character of ACII value 19 and insted of charater } is using a charater
> > of ascii value 21.
> >
> > Any ideas what to do next?
> >
> > Thanks,
> >
> > Zalek
> >
> > Jonathan West wrote:
> >> If you want to add the field by means of a VBA macro, then you use the
> >> Add
> >> method of the Fields collection. The Range property of the method defines
> >> where the field is inserted. You can insert XE and TC fields this way.
> >>
> >> The VBA help file entry for the Fields collection includes code examples
> >> for
> >> how to do this.
> >>
> >> --
> >> Regards
> >> Jonathan West - Word MVP
> >> www.intelligentdocuments.co.uk
> >> Please reply to the newsgroup
> >> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
> >>
> >> "Suzanne S. Barnhill" <sbarnhill@mvps.org> wrote in message
> >> news:OecY6YflFHA.4028@TK2MSFTNGP10.phx.gbl...
> >> > XE fields are used to create an index, TC fields a TOC. You can create
> >> > a
> >> > TOC
> >> > without using TC fields (using headings or outline levels), but you
> >> > cannot
> >> > create an index except with XE fields. See the Help topic "Field codes:
> >> > XE
> >> > (Index Entry) field" for more.
> >> >
> >> > --
> >> > Suzanne S. Barnhill
> >> > Microsoft MVP (Word)
> >> > Words into Type
> >> > Fairhope, Alabama USA
> >> > Word MVP FAQ site: http://word.mvps.org
> >> > Email cannot be acknowledged; please post all follow-ups to the
> >> > newsgroup
> >> > so
> >> > all may benefit.
> >> >
> >> > "zalek" <zalekbloom@hotmail.com> wrote in message
> >> > news:1122823164.715491.104460@g43g2000cwa.googlegroups.com...
> >> >>
> >> >> Jonathan West wrote:
> >> >> > First question. Do you want a Table of Contents (i.e. with the
> >> >> > entries
> >> > in
> >> >> > the table in the order in thich they appear in the document) or an
> >> >> > Index
> >> >> > (i.e. with the entries sorted alphabetically?
> >> >> >
> >> >> > --
> >> >> > Regards
> >> >> > Jonathan West - Word MVP
> >> >> > www.intelligentdocuments.co.uk
> >> >> > Please reply to the newsgroup
> >> >>
> >> >>
> >> >> I prefare the Index, but I would like to know codes for the Table of
> >> >> Contents too.
> >> >>
> >> >> Thanks,
> >> >>
> >> >> Zalek
> >> >>
> >> >>
> >> >> > Keep your VBA code safe, sign the ClassicVB petition
> >> >> > www.classicvb.org
> >> >> >
> >> >> > "zalek" <zalekbloom@hotmail.com> wrote in message
> >> >> > news:1122809866.433829.249290@g49g2000cwa.googlegroups.com...
> >> >> > > Hello,
> >> >> > >
> >> >> > > Here is my problem: I have an Access table with 2 columns: a
> >> >> > > keyword
> >> >> > > and a memo. From this table I want to create a Word document -
> >> >> > > this
> >> >> > > is
> >> >> > > no brainer, I know how to do it. Now the difficult part - I want
> >> >> > > to
> >> >> > > create an index table from the keyword columns (or table of
> >> > containts).
> >> >> > > My question: what are the internal values of code that mark a word
> >> >> > > an
> >> >> > > the index?
> >> >> > > I know how to do it manualy, but because the table have over
> >> >> > > thousand
> >> >> > > entries, I want to do it automaticly.
> >> >> > >
> >> >> > > Thanks,
> >> >> > >
> >> >> > > Zalek
> >> >> > >
> >> >>
> >> >
> >


Re: internal code for index or table of contents by Jonathan

Jonathan
Thu Aug 04 05:30:08 CDT 2005


"zalek" <zalekbloom@hotmail.com> wrote in message
news:1123113050.299485.265270@g49g2000cwa.googlegroups.com...
> Jonathan,
>
> I really appreciate your time - thanks for answering.
>
> Let me bug you a little more.
> I already order a few books on VBA, but meantime:
> I have a .txt file with text and list of words I want to appear in the
> Index, based on the text in my .txt file.
>
> My question:
>
> 1. What is a field object?

Without bothering with VBA, open some document, go to the Insert menu,
select "Field..." and from the dialog that appears pick some field to insert
in the document. Press Alt-F9 to toggle between displaying field codes and
field results in the document. You now know what a field is.

Open the VBA editor, display the Immediate window. In the immediate window,
type "Print ActiveDocument.Fields.Count" and press Enter. Since you have
already entered a field in the document, the value which is printed should
be 1. if you have experimented with entering more fields in the document,
the value may be higher.


> I made a test - created a word document with a few words and created a
> macro:
>
> Sub VBAtest1()
> Dim oField As Field
> Dim i As Integer
> Open "c:\vab-test.txt" For Output As #1
> i = ActiveDocument.Fields.Count
> Write #1, i
> Close #1
>
> End Sub
>
> File shows zero. So what is a Field in the document?

if you are opening a plain text file rather than a Word document, I am not
in the least bit surprised that there are no fields in it.

>
> 2. Let say in my document each field I want to index I'll write with
> prefix @@, for example if I'll want to index the word "Zalek" - I will
> write it as "@@Zalek".
> What are VBA commands that will let me scan all words in the document
> and test if they have prefix "@@"?

There are two parts of this. First you need a way to recognise every word
that starts with @@. And then you need to strip off the @@ and insert a
field after it.

For the first part, I suggest you take a look at the Find object. There are
lots of code samples in messages to this group dealing with the Find object.

Then you need to look at the Add method of the Fields collection in the VBA
help to work out how to add the field. Start out just by using the code
sample there, and just do a bit of experimenting. Also, record a macro while
inserting a field by hand isong the Insert Fields dialog, and see what the
code looks like. If you get stuck, post the code you have so far and
somebody will comment on it.

But I'm not going simply to write the code for you when you don't appear to
have looked up the references I have already given you.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org