How do I get the current line number in a macro?

L

Larry Root

In Word 2002, I need to locate and list locations at which a string is found
in the document. Once find locates the string, how do I assign the then
current line number to a variable?

Thanks for any suggestions,

Larry
 
H

Helmut Weber

Hi Larry,

basically it is
Selection.Information(wdFirstCharacterLineNumber)
which needs switching from print-view
to normal-view and back beforehand in some
higher version of word, if it should return -1
at the beginning.

In case you want something like

Word Page Line
USA 1 12
1 13
1 18
3 1
etc.

things become a bit more difficult.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
L

Larry Root

Thanks Helmut, that gives me the starting point I needed!

What I'm trying to do is create a table showing each citation to each of a
list of references and then bookmark the table and reference from that. I
cannot simply use a SEQ number in the text because I don't want to index it
for multiple references to the same work. The problem is that when I
bookmark and then reference, the numbering goes out of sequence if I move
text with the REF field.

I was planning on continuous numbering to avoid the page/line issue;
now I'm looking at ambiguities of locations within a given line.

I don't suppose MSW offers a "first use" function for bookmarks that could
be tested in an IF/THEN statement?

Thanks again.
Very Respectfully,
Larry
 
H

Helmut Weber

Hi Larry,

I'm no good at all at fields like SEQ.
In my opinion it is rather advanced use of features then programming.
I don't suppose MSW offers a "first use" function for bookmarks that could
be tested in an IF/THEN statement?

Bookmarks are unique, so there is no first use. ?

If you have a table with pieces of text and want to build
a list with occurences (page, line) I'd do it simply by searching,
get the page number and the line number, either for the first
occurence or for more or for all. Not much of a problem,
except some extra code lines to cover the issue, that all pieces
of text will be found, as there are in the table in the very same
document.

HTH

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

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