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 )

enter image description here

and how want look

enter image description here

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. enter image description here


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -