Get line width from a range object in Word 2003 VBA

M

Markus

Hello,
I have a problem in programming word VBA.
I want to insert graphs from the cliboard into a word document at all the
positions where '[[Graph]]' is written. To setup the graph in the other
program (MATLAB), I need the width of the line of the text column (the
document has more than one column) the graph is pasted in. I locate the range
objects with range.Find.execute "[[Graph]]". How can I get the width of the
text column of this range object?

Best regards
Markus
 
H

Helmut Weber

Hi Markus,

frankly speaking, I don't know,
or better, I didn't find a straightforward way,
to determine in which textcolumn a range is located,
if it doesn't span over textcolumns, of course.

But you can get the position of a range's start.

Dim rTmp As Range
Set rTmp = Selection.Range
MsgBox rTmp.Information(wdHorizontalPositionRelativeToTextBoundary)

And you can get the width of a textcolumn.

MsgBox ActiveDocument.PageSetup.TextColumns(1).Width

if wdHorizontalPositionRelativeToTextBoundary
is within
ActiveDocument.PageSetup.TextColumns(1).Width
then the range starts in the first textcolumn.

Alright?

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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