Frank Lekens
2011-09-17 08:40:04 UTC
I'm trying to do the following: convert text to a table, and use the
'autowidth' feature for the columns.
If I do this manually, it works fine.
I record a macro doing the same thing, and it works fine.
The text of the recorded macro looks like this in Office 2007:
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
WordBasic.TextToTable ConvertFrom:=1, NumColumns:=3, NumRows:=21, _
InitialColWidth:=wdAutoPosition, Format:=0, Apply:=1184,
AutoFit:=1, _
SetDefault:=0, Word8:=0, Style:="Tabelraster"
And it looks like this if I record it in Office 2003:
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
NumRows:=39, AutoFitBehavior:=wdAutoFitContent
With Selection.Tables(1)
.Style = "Tabelraster"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
I see the relevant values, AutoFitBehavior:=wdAutoFitContent and AutoFit=1.
But the strange thing: if I perform the macro on the very same text, the
columns are not autofitted. Instead, all three columns are of equal
width (whereas I'd like the third to be much broader, as it contains
more text).
Is there anything I can change or add to the macro text to make it work?
(And incidentally, can I just remove the text specifying the number of
rows from the macro, since this will vary depending on the text the
macro is performed on?)
MTIA.
'autowidth' feature for the columns.
If I do this manually, it works fine.
I record a macro doing the same thing, and it works fine.
The text of the recorded macro looks like this in Office 2007:
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
WordBasic.TextToTable ConvertFrom:=1, NumColumns:=3, NumRows:=21, _
InitialColWidth:=wdAutoPosition, Format:=0, Apply:=1184,
AutoFit:=1, _
SetDefault:=0, Word8:=0, Style:="Tabelraster"
And it looks like this if I record it in Office 2003:
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
NumRows:=39, AutoFitBehavior:=wdAutoFitContent
With Selection.Tables(1)
.Style = "Tabelraster"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
I see the relevant values, AutoFitBehavior:=wdAutoFitContent and AutoFit=1.
But the strange thing: if I perform the macro on the very same text, the
columns are not autofitted. Instead, all three columns are of equal
width (whereas I'd like the third to be much broader, as it contains
more text).
Is there anything I can change or add to the macro text to make it work?
(And incidentally, can I just remove the text specifying the number of
rows from the macro, since this will vary depending on the text the
macro is performed on?)
MTIA.
--
Frank Lekens
www.xs4all.nl/~fmlekens
Frank Lekens
www.xs4all.nl/~fmlekens