Skipping a column/row in a table based on its dimensions using VBA in Word -
so i'm creating label making macro on word copy , paste 1 label specified amount of labels. problem table set there 1 blank column between each label, , 1 blank row between each row of labels. there 7 labels in each row, 17 in each column. place label created has height of 0.5" , width of 0.94". columns in-between have 0.13" width, , rows in-between have 0.13" height. wrote code based on cell dimensions. but, not working. doesn't give error, pastes every cell instead of skipping ones small. picture of label template attached. i'm not sure if best way it, insight appreciated!
sub labels() dim tbl table set tbl = activedocument.tables(1) = 1 labels2.textbox3.value if tbl.rows.height < 0.5 , tbl.columns.width < 0.9 selection.moveright unit:=wdcharacter, count:=2 else selection.paste selection.moveright unit:=wdcharacter, count:=2 end if next end sub
if know need skip column between each label , row between each row can this:
sub labels() dim numlabels long, long dim tbl table, rw long, c long set tbl = activedocument.tables(1) numlabels = 10 = 0 rw = 1 tbl.rows.count step 2 c = 1 tbl.columns.count step 2 tbl.cell(rw, c).range.paste = + 1 if = numlabels goto done next c next rw done: msgbox "labels created" end sub
Comments
Post a Comment