Word deleting tabe column via vba macros gives an error

前端 未结 2 1832
清酒与你
清酒与你 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
    
    0 讨论(0)
  • 2021-01-25 20:44

    Sleep function might work.

    Declare Sub Sleep Lib "kernel32" Alias "Sleep" _
       (ByVal dwMilliseconds As Long)
    
    Sub Sleep()
    
    Sleep 1000   'Implements a 1 second delay
    
    End Sub
    
    0 讨论(0)
提交回复
热议问题