i'm trying create one-to-many merge in word using excel vba. i've gotten form work expected when manually running process in word 2013.
however, when try automate using vba in excel 2013, somehow defaults , inserts page breaks each new row in excel spreadsheet. here code altered source following code block:
dim cdir string dim thisfilename string const wtempname = "hccmailmerge.docx" 'this word templates name dim newfilename string newfilename = "testing123" ' setup directory cdir = activeworkbook.path + "\" thisfilename = thisworkbook.name 'open word template set objmmmd = objword.documents.open(cdir + wtempname) objmmmd.activate 'merge data objmmmd.mailmerge .opendatasource _ name:=cdir + thisfilename, _ sqlstatement:="select * `data$`" .destination = wdsendtonewdocument .maindocumenttype = wdcatalog .execute pause:=false end
automating mail merge using excel vba
i assumed when changed .maindocumenttype = wdcatalog
suppress page breaks. not case.
any appreciated.
Comments
Post a Comment