vba - Header when creating report from Excel to Word -
i have code creates header in word excel:
wdapp.activewindow.activepane.view.seekview = 9 wdapp.selection.typetext thisworkbook.worksheets("rapport").range("i4").text wdapp.activewindow.activepane.view.seekview = 0 selection.paragraphformat.alignment = wdalignparagraphjustify
but error occurs on last row.
want create row want header nice centerd.
this how using code. ( not want )
and how want look
option 1: try change order of instructions and, important, need add special line break character @ , 'justification result'. here example:
selection.paragraphformat.alignment = wdalignparagraphjustify selection.typetext "here text excel" + chr(11)
option 2: however, justification not give result presented aligning words add spaced between each word. result have need add table go this:
dim tmptbl table set tmptbl = selection.tables.add(selection.range, 1, 2) tmptbl.cell(1, 1).range .text = "date: " & .paragraphformat.alignment = wdalignparagraphleft end with tmptbl.cell(1, 2).range .text = "here text excel" .paragraphformat.alignment = wdalignparagraphright end
the following screen shot presents both options.
Comments
Post a Comment