How to get the hight of context in a Microsoft word in C#?

V

vincent

I need to know the hight of context in a Microsoft word.
Then set the Page hight equte the hight of context.
Does anyone know how to do that?
 
R

Russ

I am not sure what you want.
If you want to view one page in the window, then use the menu 'View/Page
Layout', then move to the 'Zoom' dropdown list in the main toolbar and
select 'Whole Page'. If you want to go to a certain page use menu Edit/Go
To...
 
V

vincent

thank you very much.

Russ said:
I am not sure what you want.
If you want to view one page in the window, then use the menu 'View/Page
Layout', then move to the 'Zoom' dropdown list in the main toolbar and
select 'Whole Page'. If you want to go to a certain page use menu Edit/Go
To...
 
V

vincent

I use Word Application object to operate a Microsoft Word file.

I would like to know the current the hight of a specific cell in the table.

When the HeightRule is wdRowHeighAuto and the Height propertys always be
9999999.0.

How to do get the current Height of the cell?

// Declaring the object variables we will need later
object varFileName = "c:\\test\\CellTest.docx";
object varFalseValue = false;
object varTrueValue = true;
object varMissing = Type.Missing;
// Create a reference to MS Word application
Microsoft.Office.Interop.Word.Application varWord = new
Microsoft.Office.Interop.Word.Application();
//set printer
varWord.ActivePrinter = "Microsoft Office Live Meeting
Document Writer";
// Creates a reference to a word document
Microsoft.Office.Interop.Word.Document varDoc =
varWord.Documents.Open(ref varFileName, ref varMissing, ref varFalseValue,
ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing,
ref varMissing, ref varMissing, ref varMissing, ref varMissing);
// Activate the document
varDoc.Activate();



string HeightRule =varDoc.Tables[1].Cell(0, 0).HeightRule.ToString();
float testHight=varDoc.Tables[1].Cell(0, 0).Height;
 
D

Doug Robbins - Word MVP

The difference between
Selection.Information(wdVerticalPositionRelativeToPage) for the text in the
cell in question and that in the cell in the next row should give you what
you want.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

vincent said:
I use Word Application object to operate a Microsoft Word file.

I would like to know the current the hight of a specific cell in the
table.

When the HeightRule is wdRowHeighAuto and the Height propertys always be
9999999.0.

How to do get the current Height of the cell?

// Declaring the object variables we will need later
object varFileName = "c:\\test\\CellTest.docx";
object varFalseValue = false;
object varTrueValue = true;
object varMissing = Type.Missing;
// Create a reference to MS Word application
Microsoft.Office.Interop.Word.Application varWord = new
Microsoft.Office.Interop.Word.Application();
//set printer
varWord.ActivePrinter = "Microsoft Office Live Meeting
Document Writer";
// Creates a reference to a word document
Microsoft.Office.Interop.Word.Document varDoc =
varWord.Documents.Open(ref varFileName, ref varMissing, ref varFalseValue,
ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing,
ref varMissing, ref varMissing, ref varMissing, ref varMissing);
// Activate the document
varDoc.Activate();



string HeightRule =varDoc.Tables[1].Cell(0, 0).HeightRule.ToString();
float testHight=varDoc.Tables[1].Cell(0, 0).Height;




Russ said:
I am not sure what you want.
If you want to view one page in the window, then use the menu 'View/Page
Layout', then move to the 'Zoom' dropdown list in the main toolbar and
select 'Whole Page'. If you want to go to a certain page use menu Edit/Go
To...
 
V

vincent

Thank you very much for your replying.
Thank you.

Doug Robbins - Word MVP said:
The difference between
Selection.Information(wdVerticalPositionRelativeToPage) for the text in the
cell in question and that in the cell in the next row should give you what
you want.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

vincent said:
I use Word Application object to operate a Microsoft Word file.

I would like to know the current the hight of a specific cell in the
table.

When the HeightRule is wdRowHeighAuto and the Height propertys always be
9999999.0.

How to do get the current Height of the cell?

// Declaring the object variables we will need later
object varFileName = "c:\\test\\CellTest.docx";
object varFalseValue = false;
object varTrueValue = true;
object varMissing = Type.Missing;
// Create a reference to MS Word application
Microsoft.Office.Interop.Word.Application varWord = new
Microsoft.Office.Interop.Word.Application();
//set printer
varWord.ActivePrinter = "Microsoft Office Live Meeting
Document Writer";
// Creates a reference to a word document
Microsoft.Office.Interop.Word.Document varDoc =
varWord.Documents.Open(ref varFileName, ref varMissing, ref varFalseValue,
ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing,
ref varMissing, ref varMissing, ref varMissing, ref varMissing);
// Activate the document
varDoc.Activate();



string HeightRule =varDoc.Tables[1].Cell(0, 0).HeightRule.ToString();
float testHight=varDoc.Tables[1].Cell(0, 0).Height;




Russ said:
I am not sure what you want.
If you want to view one page in the window, then use the menu 'View/Page
Layout', then move to the 'Zoom' dropdown list in the main toolbar and
select 'Whole Page'. If you want to go to a certain page use menu Edit/Go
To...

I need to know the hight of context in a Microsoft word.
Then set the Page hight equte the hight of context.
Does anyone know how to do that?
 
V

vincent

can you give a c# example
Thank you very much.

Doug Robbins - Word MVP said:
The difference between
Selection.Information(wdVerticalPositionRelativeToPage) for the text in the
cell in question and that in the cell in the next row should give you what
you want.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

vincent said:
I use Word Application object to operate a Microsoft Word file.

I would like to know the current the hight of a specific cell in the
table.

When the HeightRule is wdRowHeighAuto and the Height propertys always be
9999999.0.

How to do get the current Height of the cell?

// Declaring the object variables we will need later
object varFileName = "c:\\test\\CellTest.docx";
object varFalseValue = false;
object varTrueValue = true;
object varMissing = Type.Missing;
// Create a reference to MS Word application
Microsoft.Office.Interop.Word.Application varWord = new
Microsoft.Office.Interop.Word.Application();
//set printer
varWord.ActivePrinter = "Microsoft Office Live Meeting
Document Writer";
// Creates a reference to a word document
Microsoft.Office.Interop.Word.Document varDoc =
varWord.Documents.Open(ref varFileName, ref varMissing, ref varFalseValue,
ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing, ref varMissing, ref varMissing, ref varMissing, ref
varMissing,
ref varMissing, ref varMissing, ref varMissing, ref varMissing);
// Activate the document
varDoc.Activate();



string HeightRule =varDoc.Tables[1].Cell(0, 0).HeightRule.ToString();
float testHight=varDoc.Tables[1].Cell(0, 0).Height;




Russ said:
I am not sure what you want.
If you want to view one page in the window, then use the menu 'View/Page
Layout', then move to the 'Zoom' dropdown list in the main toolbar and
select 'Whole Page'. If you want to go to a certain page use menu Edit/Go
To...

I need to know the hight of context in a Microsoft word.
Then set the Page hight equte the hight of context.
Does anyone know how to do that?
 

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