문제

I am trying to automate conversion of text to a table. When I selected "Auto-fit to contents" while recording a macro, I got the following code:

    WordBasic.TextToTable ConvertFrom:=1, NumColumns:=2, NumRows:=6, _
    InitialColWidth:=wdAutoPosition, Format:=0, Apply:=1184, AutoFit:=1, _
    SetDefault:=0, Word8:=0, Style:="Table Grid"

However, when I run this code as part of the unchanged recorded macro, it does not auto-fit to contents. Anyone have any ideas where I went wrong?

I want it to autofit based on content, but the macro recorder won't record that part. I'm in ms word 2007. I've googled for 30 minutes but to no avail on what to do.

도움이 되었습니까?

해결책

To auto-fit to the contents, I added the last line below:

WordBasic.TextToTable ConvertFrom:=1, NumColumns:=2, NumRows:=6, _
InitialColWidth:=wdAutoPosition, Format:=0, Apply:=1184, AutoFit:=1, _
SetDefault:=0, Word8:=0, Style:="Table Grid"
Selection.Tables(1).AutoFitBehavior wdAutoFitContent     ' *** Added this
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top