Word. VC++6.0. How I can retrieve current number row?

A

Antonio

Hello,
I have an application in VC++ 6.0. This application creates a .DOC file for
Word2007. In this file I insert text and image (.bmp)

This is my problem:
When I insert text and/or image how I can retrieve current row?
I need to get current number row. Someone can help me with sample code in
VC++?

Thanks
 
J

Jean-Guy Marcil

Antonio said:
Hello,
I have an application in VC++ 6.0. This application creates a .DOC file for
Word2007. In this file I insert text and image (.bmp)

This is my problem:
When I insert text and/or image how I can retrieve current row?
I need to get current number row. Someone can help me with sample code in
VC++?

What do you mean by "Row"?
Are you inserting your text and bitmap in a table?
If not, there is a "line" property in Word 2003 and above, but it is not
straight forward to use...

What do you mean by "Current"? Since you are automating the document
creation, there is no such thing as a "Current" selection.

Once you answer these questions, I can probably provide sample code in VBA,
not C++, you will need to translate it...

Finally, why don't you tell us why you need this information...? There might
be an easier way of doing things... If you use the Range object, you do not
need to know "line number" to know where you are at...
 
A

Antonio

Thanks for reply. Excuse my not perfect english.
I need retrieve information from status bar.
Cursor position: current line (row).
When I produce a .DOC file (insert text) with my application in VC++6.0 I
must know at what line number I have reached.
I hope have being clear.

Bye
 
J

Jean-Guy Marcil

Antonio said:
Thanks for reply. Excuse my not perfect english.
I need retrieve information from status bar.
Cursor position: current line (row).
When I produce a .DOC file (insert text) with my application in VC++6.0 I
must know at what line number I have reached.
I hope have being clear.


In VBA, you need:

MsgBox Selection.Information(wdFirstCharacterLineNumber)

You can also use this with the Range object:

Dim rngCurrent As Range

Set rngCurrent = Selection.Range

With rngCurrent
MsgBox .Information(wdFirstCharacterLineNumber)
End With


But why do you need this? You can't really use that to do anything at all
while building a document...
 
A

Antonio

I need to control end of page.
In this document there are pictures, tables. I need formatting this element
in paper...
There is a alternative mode for to control to pass next page?
 
J

Jean-Guy Marcil

Antonio said:
I need to control end of page.
In this document there are pictures, tables. I need formatting this element
in paper...
There is a alternative mode for to control to pass next page?

If you mean that you will monitor the "wdFirstCharacterLineNumber" value
before and after every move you make, then, yes, you can use that to detect
if you have moved on to a new page. You could also use
".Information(wdActiveEndPageNumber)". Also, you could just get the total
number of pages in the document ".Information(wdNumberOfPagesInDocument)"...
Whenever it increases, you have just added a page.

Make sure you use a "Range" object and not the "Selection" object. It will
make your code more reliable and faster to execute.
 
A

Antonio

Thanks for information.
Now I must translate your information in VC++.
I hope to find right correspondence.

Bye
 

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