Word deleting tabe column via vba macros gives an error -
i want copy data excel word table , delete columns table. can copy data table, when delete column gives error:
cannot access individual columns in collection because table has mixed cell widths.
my code:
public tbl1 table sub callexcel() dim objexcel new excel.application dim exwb excel.workbook set exwb = objexcel.workbooks.open("c:\users\ismayilov\desktop\test") roomnumber = inputbox("enter room number copy word:", "room number") activedocument.formfields("text1").result = roomnumber exwb.sheets("sheet1").range("$a:$h").autofilter field:=8, criteria1:=roomnumber dim rvis range, rdata range exwb.sheets("sheet1").range("$a1:$h600").copy set tbl1 = activedocument.tables.add _ (range:=selection.range, numrows:=1, numcolumns:=8) tbl1.range.paste tbl1.columns(1).delete exwb.close savechanges:=true set exwb = nothing set tbl1 = nothing end sub
try change line:
tbl1.range.paste
into following one:
tbl1.range.pasteappendtable
edit seems .pasteappendtable
requires time invoked. therefore try add additional section:
'...your code 'let's wait second before pasting (could cut 0.5 sec) dim tmpstart tmpstart = timer doevents loop while (tmpstart + 1) > timer tbl1.range.pasteappendtable '...your code
Comments
Post a Comment