 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
None Guest
|
Posted: Tue Dec 26, 2006 10:44 pm Post subject: Word 2K ParagraphFormat |
|
|
I know this is a Delphi group, but I'm having problems with MS Word OLE with
Borland Builder 6 (is there a better place for this post?). I've been
banging my head for a week on this...
I created a table and want to set the "KeepWithNext" on some of the lines
but my request seems to always be ignored. In particular, I'm doing:
mCurrentTable =
WordDocument->Tables->Add(WordApplication->Selection->Range, 2, mMaxDays+3);
mCurrentTable->AutoFormat(TVariant(wdTableFormatGrid1));
SetFontTable("Times New Roman", 10, mCurrentTable);
mCurrentTable->Columns->Item(1)->SetWidth(WordApplication->InchesToPoints(1.0),wdAdjustSameWidth);
// Display Name
mCurrentTable->Columns->Item(2)->SetWidth(WordApplication->InchesToPoints(0.3),wdAdjustSameWidth);
// APE
for (int day=1; day<=mMaxDays; ++day) {
mCurrentTable->Columns->Item(2+day)->SetWidth(WordApplication->InchesToPoints(0.31),
wdAdjustSameWidth); // days
}
mCurrentTable->Columns->Item(mMaxDays+3)->SetWidth(WordApplication->InchesToPoints(2.2),
wdAdjustSameWidth); // Comments
After I do this, to set the KeepWithNext, I tried using a selection:
mCurrentTable->Cell(1,1)->Range->Select();
WordApplication->Selection->ParagraphFormat->KeepWithNext = true;
I would then look at the document in cell 1,1 of the table and go to the
"Paragraph" "Line and Page breaks" tab. I don't see the KeepWithNext option
being set.
Then I did the following:
Word_2k::_ParagraphFormat *parag;
parag = mCurrentTable->Cell(1, 1)->Range->ParagraphFormat;
parag->KeepWithNext = true;
bool flag = mCurrentTable->Cell(1,
1)->Range->ParagraphFormat->KeepWithNext;
bool flag3 = parag->KeepWithNext;
When I look at flag3 and flag2, they always come back as false...
I'm able to use the Visual Basic Editor within Word and have no problem
setting the KeepWithNext flag.
Any idea what I'm doing wrong?
I assume there isn't a problem with me having Word 2002 installed but using
the Office 2000 OLE interface. Also, is there a way to use the Office XP
OLE interface?
Paul |
|
| Back to top |
|
 |
Oliver Townshend Guest
|
Posted: Wed Dec 27, 2006 1:37 am Post subject: Re: Word 2K ParagraphFormat |
|
|
| Quote: | I assume there isn't a problem with me having Word 2002 installed but
using the Office 2000 OLE interface. Also, is there a way to use the
Office XP OLE interface?
|
In Delphi we just import the appropriate type library. But generally that
which works with 2000 will work on XP, but not vice versa, so working on
2000 is quite safe.
Why would keep with next in a table cell matter? How does it interact with
the other cells? Surely you need to set the row properties for page
breaking instead?
Oliver Townshend |
|
| Back to top |
|
 |
None Guest
|
Posted: Wed Dec 27, 2006 2:31 am Post subject: Re: Word 2K ParagraphFormat |
|
|
"Oliver Townshend" <oliveratzipdotcomdotau> wrote in message
news:459179c9$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I assume there isn't a problem with me having Word 2002 installed but
using the Office 2000 OLE interface. Also, is there a way to use the
Office XP OLE interface?
In Delphi we just import the appropriate type library. But generally that
which works with 2000 will work on XP, but not vice versa, so working on
2000 is quite safe.
I dropped a WordApplication and WordDocument component onto my form (from |
the "Office2k" tab of Builders components palette). I assume there is a way
of using OLE without using these components.
| Quote: | Why would keep with next in a table cell matter? How does it interact
with the other cells? Surely you need to set the row properties for page
breaking instead?
I want to PREVENT a line-break between a particular row and the following |
row in the table.
I have a grouping of three types of rows (say A, B, and C) and they repeat
throughout the table (i.e. A, B, C, A, B, C, A, B, C, etc). I want to
prevent a page break between rows A and B as well as prevent a page break
between rows B and C. However, it is acceptable to have a page break between
C and A.
Setting a cell to be kept with the cell in the next row prevents the line
break. I've also attempted to KeepWithNext on the entire row and again this
doesn't seem to work for me either.
Doing this within Word (manually as well as with VB) seems to work... I've
also having problems setting the "Repeat as Header Row" (i.e.
HeadingFormat ) of a row.
Paul |
|
| Back to top |
|
 |
Oliver Townshend Guest
|
Posted: Wed Dec 27, 2006 4:03 am Post subject: Re: Word 2K ParagraphFormat |
|
|
| Quote: | I dropped a WordApplication and WordDocument component onto my form (from
the "Office2k" tab of Builders components palette). I assume there is a
way of using OLE without using these components.
|
Yes there is, you can just use the .pas files created from the import, and
create the objects and access them using interfaces. At least that's what
you can do in Delphi. There's lots of good examples at
http://www.djpate.freeserve.co.uk/Automation.htm.
| Quote: | Doing this within Word (manually as well as with VB) seems to work...
I've also having problems setting the "Repeat as Header Row" (i.e.
HeadingFormat ) of a row.
|
Can we see your VB code to compare it to the C++ code? What problems are
you having with Repeat as Header Row?
On an entirely different note, have you considered using Styles to control
formatting?
Oliver Townshend |
|
| Back to top |
|
 |
None Guest
|
Posted: Tue Mar 27, 2007 4:23 am Post subject: Re: Word 2K ParagraphFormat |
|
|
I posted this awhile ago and still haven't figured it out... Any idea what
is going on?
Paul
"None" <None (AT) none (DOT) com> wrote in message
news:45915146 (AT) newsgroups (DOT) borland.com...
| Quote: | I know this is a Delphi group, but I'm having problems with MS Word OLE
with Borland Builder 6 (is there a better place for this post?). I've been
banging my head for a week on this...
I created a table and want to set the "KeepWithNext" on some of the lines
but my request seems to always be ignored. In particular, I'm doing:
mCurrentTable =
WordDocument->Tables->Add(WordApplication->Selection->Range, 2,
mMaxDays+3);
mCurrentTable->AutoFormat(TVariant(wdTableFormatGrid1));
SetFontTable("Times New Roman", 10, mCurrentTable);
mCurrentTable->Columns->Item(1)->SetWidth(WordApplication->InchesToPoints(1.0),wdAdjustSameWidth);
mCurrentTable->Columns->Item(2)->SetWidth(WordApplication->InchesToPoints(0.3),wdAdjustSameWidth);
for (int day=1; day<=mMaxDays; ++day) {
mCurrentTable->Columns->Item(2+day)->SetWidth(WordApplication->InchesToPoints(0.31),
wdAdjustSameWidth); }
mCurrentTable->Columns->Item(mMaxDays+3)->SetWidth(WordApplication->InchesToPoints(2.2),
wdAdjustSameWidth);
After I do this, to set the KeepWithNext, I tried using a selection:
mCurrentTable->Cell(1,1)->Range->Select();
WordApplication->Selection->ParagraphFormat->KeepWithNext = true;
I would then look at the document in cell 1,1 of the table and go to the
"Paragraph" "Line and Page breaks" tab. I don't see the KeepWithNext
option being set.
Then I did the following:
Word_2k::_ParagraphFormat *parag;
parag = mCurrentTable->Cell(1, 1)->Range->ParagraphFormat;
parag->KeepWithNext = true;
bool flag = mCurrentTable->Cell(1,
1)->Range->ParagraphFormat->KeepWithNext;
bool flag3 = parag->KeepWithNext;
When I look at flag3 and flag2, they always come back as false...
I'm able to use the Visual Basic Editor within Word and have no problem
setting the KeepWithNext flag.
Any idea what I'm doing wrong?
I assume there isn't a problem with me having Word 2002 installed but
using the Office 2000 OLE interface. Also, is there a way to use the
Office XP OLE interface?
Paul
|
|
|
| Back to top |
|
 |
None Guest
|
Posted: Tue Mar 27, 2007 6:14 am Post subject: Re: Word 2K ParagraphFormat |
|
|
After I create a table, running this VB Macro works fine to set all rows but
the last to KeepWithNext :
Sub Test()
Dim myTable As Table
Dim myRange As Range
Set myTable = ActiveDocument.Tables(1)
Set myRange = myTable.Range
myRange.End = myTable.Rows.Last.Previous.Range.End
myRange.ParagraphFormat.KeepWithNext = True
End Sub
However, doing this has no effect in Borland Builder 6:
WordDocument->Tables->Item(1)->Range->End =
WordDocument->Tables->Item(1)->Rows->Last->Previous->Range->End;
WordDocument->Tables->Item(1)->Range->ParagraphFormat->KeepWithNext =
true;
I'm using Word_2K OLE.
"None" <None (AT) none (DOT) com> wrote in message
news:460855ce$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I posted this awhile ago and still haven't figured it out... Any idea what
is going on?
Paul
"None" <None (AT) none (DOT) com> wrote in message
news:45915146 (AT) newsgroups (DOT) borland.com...
I know this is a Delphi group, but I'm having problems with MS Word OLE
with Borland Builder 6 (is there a better place for this post?). I've been
banging my head for a week on this...
I created a table and want to set the "KeepWithNext" on some of the lines
but my request seems to always be ignored. In particular, I'm doing:
mCurrentTable =
WordDocument->Tables->Add(WordApplication->Selection->Range, 2,
mMaxDays+3);
mCurrentTable->AutoFormat(TVariant(wdTableFormatGrid1));
SetFontTable("Times New Roman", 10, mCurrentTable);
mCurrentTable->Columns->Item(1)->SetWidth(WordApplication->InchesToPoints(1.0),wdAdjustSameWidth);
mCurrentTable->Columns->Item(2)->SetWidth(WordApplication->InchesToPoints(0.3),wdAdjustSameWidth);
for (int day=1; day<=mMaxDays; ++day) {
mCurrentTable->Columns->Item(2+day)->SetWidth(WordApplication->InchesToPoints(0.31),
wdAdjustSameWidth); }
mCurrentTable->Columns->Item(mMaxDays+3)->SetWidth(WordApplication->InchesToPoints(2.2),
wdAdjustSameWidth);
After I do this, to set the KeepWithNext, I tried using a selection:
mCurrentTable->Cell(1,1)->Range->Select();
WordApplication->Selection->ParagraphFormat->KeepWithNext = true;
I would then look at the document in cell 1,1 of the table and go to the
"Paragraph" "Line and Page breaks" tab. I don't see the KeepWithNext
option being set.
Then I did the following:
Word_2k::_ParagraphFormat *parag;
parag = mCurrentTable->Cell(1, 1)->Range->ParagraphFormat;
parag->KeepWithNext = true;
bool flag = mCurrentTable->Cell(1,
1)->Range->ParagraphFormat->KeepWithNext;
bool flag3 = parag->KeepWithNext;
When I look at flag3 and flag2, they always come back as false...
I'm able to use the Visual Basic Editor within Word and have no problem
setting the KeepWithNext flag.
Any idea what I'm doing wrong?
I assume there isn't a problem with me having Word 2002 installed but
using the Office 2000 OLE interface. Also, is there a way to use the
Office XP OLE interface?
Paul
|
|
|
| Back to top |
|
 |
Oliver Guest
|
Posted: Tue Mar 27, 2007 8:12 am Post subject: Re: Word 2K ParagraphFormat |
|
|
| Quote: | Set myTable = ActiveDocument.Tables(1)
Set myRange = myTable.Range
myRange.End = myTable.Rows.Last.Previous.Range.End
myRange.ParagraphFormat.KeepWithNext = True
End Sub
However, doing this has no effect in Borland Builder 6:
WordDocument->Tables->Item(1)->Range->End =
WordDocument->Tables->Item(1)->Rows->Last->Previous->Range->End;
WordDocument->Tables->Item(1)->Range->ParagraphFormat->KeepWithNext =
true;
|
What happens if you make your C++ function look like your Macro?
Oliver Townshend |
|
| Back to top |
|
 |
None Guest
|
Posted: Wed Mar 28, 2007 1:38 am Post subject: Re: Word 2K ParagraphFormat |
|
|
Make it "appear" similar to the macro version is no different (i.e. it
doesn't work):
Word_2k::Table *myTable = WordDocument->Tables->Item(1);
Word_2k::Range *myRange = myTable->Range;
myRange->End = myTable->Rows->Last->Previous->Range->End;
myRange->ParagraphFormat->KeepWithNext = true;
Do you have a problem when you use Delphi (I do not have it) to do this??.
Paul P.
"Oliver" <oliveratcodelegaldotcomdotau> wrote in message
news:4608a945 (AT) newsgroups (DOT) borland.com...
| Quote: | Set myTable = ActiveDocument.Tables(1)
Set myRange = myTable.Range
myRange.End = myTable.Rows.Last.Previous.Range.End
myRange.ParagraphFormat.KeepWithNext = True
End Sub
However, doing this has no effect in Borland Builder 6:
WordDocument->Tables->Item(1)->Range->End =
WordDocument->Tables->Item(1)->Rows->Last->Previous->Range->End;
WordDocument->Tables->Item(1)->Range->ParagraphFormat->KeepWithNext =
true;
What happens if you make your C++ function look like your Macro?
Oliver Townshend |
|
|
| Back to top |
|
 |
Oliver Guest
|
Posted: Wed Mar 28, 2007 2:26 pm Post subject: Re: Word 2K ParagraphFormat |
|
|
| Quote: | Do you have a problem when you use Delphi (I do not have it) to do this??.
|
Personally, I use Styles to do my formatting. Much neater.
Oliver Townshend |
|
| Back to top |
|
 |
None Guest
|
Posted: Sun Apr 01, 2007 1:53 am Post subject: Re: Word 2K ParagraphFormat |
|
|
I could not figure out how to set the style for a row in a table.. I also
could not figure out how to create a new style based on an existing style.
Do you have examples of using styles in tables?
"Oliver" <oliveratcodelegaldotcomdotau> wrote in message
news:460a351b (AT) newsgroups (DOT) borland.com...
| Quote: | Do you have a problem when you use Delphi (I do not have it) to do
this??.
Personally, I use Styles to do my formatting. Much neater.
Oliver Townshend |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|