Word deleting tabe column via vba macros gives an error

前端 未结 2 1836
清酒与你
清酒与你 2021-01-25 20:18

I want to copy data from excel to the word table and then delete some columns from table. I can copy data to table, but when I delete column it gives error:

2条回答
  •  醉梦人生
    2021-01-25 20:37

    Try to change this line:

    Tbl1.Range.Paste
    

    into the following one:

    tbl1.Range.PasteAppendTable
    

    EDIT It seems that .PasteAppendTable requires some time to be invoked. Therefore try to add this additional section:

    '...your code
    
    'let's wait a second before pasting (could be cut to 0.5 sec)
    Dim tmpStart
    tmpStart = Timer
    Do
        DoEvents
    Loop While (tmpStart + 1) > Timer
    
    tbl1.Range.PasteAppendTable
    
    '...your code
    

提交回复
热议问题