H
Harald Mueller
Hi,
I encounter a problem with table borders. I wrote a Word macro
which creates a new table with the following parameters:
Set oTable = ActiveDocument.Tables.Add(Selection.Range, NumColumns:=3, NumRows:=1)
With oTable
.Borders.Enable = True
.Borders.InsideLineStyle = wdLineStyleSingle
.Borders.OutsideLineStyle = wdLineStyleSingle
.Columns(1).Width = 100
.Columns(2).Width = 50
.PreferredWidthType = wdPreferredWidthPercent
.PreferredWidth = 100
End With
So I get a table with the width of the entire page, the desired columns and
a border around it. So, if I start the macro out of the Word VB Editor it
runs just fine and I get the correct table.
But the purpose of this macro is that it should run inside an application.
So, if I run it inside the application which uses the Macro, the table is
created with the correct size and columns, but the border is not enabled.
I debugged it and looked at the behavior of oTable.Borders.Enable.
If I run it inside Word it gets set to "-1" at the time the program steps
into the with-block, and the table gets its border. Manually changing
it to 0 (through double-clicking it in the debug window) is possible
and disables the border, manually changing it back to "-1" enables the
border again.
But if I debug it inside the application, it is not possible to change the
value manually. If I set it to something different than 0, it hops back to
0 all the time. The value also gets never ever a different value than 0
programmatically.
So I'm wondering if it is possible to give the Borders.Enable a kind of a
write-protection? The application uses a lot of VBA to export the data
of a different application into a Word document, so could it be something
there, as all is working correctly when used stand-alone but not when called
from the application? I mean, it's hard to imagine that the same code is
working in one place but won't in another.
I'm grateful for every hint what it could be, because I don't know what I could
do now.
I encounter a problem with table borders. I wrote a Word macro
which creates a new table with the following parameters:
Set oTable = ActiveDocument.Tables.Add(Selection.Range, NumColumns:=3, NumRows:=1)
With oTable
.Borders.Enable = True
.Borders.InsideLineStyle = wdLineStyleSingle
.Borders.OutsideLineStyle = wdLineStyleSingle
.Columns(1).Width = 100
.Columns(2).Width = 50
.PreferredWidthType = wdPreferredWidthPercent
.PreferredWidth = 100
End With
So I get a table with the width of the entire page, the desired columns and
a border around it. So, if I start the macro out of the Word VB Editor it
runs just fine and I get the correct table.
But the purpose of this macro is that it should run inside an application.
So, if I run it inside the application which uses the Macro, the table is
created with the correct size and columns, but the border is not enabled.
I debugged it and looked at the behavior of oTable.Borders.Enable.
If I run it inside Word it gets set to "-1" at the time the program steps
into the with-block, and the table gets its border. Manually changing
it to 0 (through double-clicking it in the debug window) is possible
and disables the border, manually changing it back to "-1" enables the
border again.
But if I debug it inside the application, it is not possible to change the
value manually. If I set it to something different than 0, it hops back to
0 all the time. The value also gets never ever a different value than 0
programmatically.
So I'm wondering if it is possible to give the Borders.Enable a kind of a
write-protection? The application uses a lot of VBA to export the data
of a different application into a Word document, so could it be something
there, as all is working correctly when used stand-alone but not when called
from the application? I mean, it's hard to imagine that the same code is
working in one place but won't in another.
I'm grateful for every hint what it could be, because I don't know what I could
do now.