VBA Copy selected cells with data (Excel). Paste them in specific row in a table (Word) -


i have following case:

in excel spreadsheet, there data (names, email, phone number, id number, etc.) same data should populated given word form (it exists protection on word file allows several rows table filled in). copy existing data excel file , paste word file on proper place (i meant cell id number copied , pasted row title id number, example).

sorry if 1 simple question, begginer in vba developing , current knowledge limited excel actions only.

thank in advance!

i starting with:

'copy  set objselection = selection  selection.copy  'paste copied  set objtempworkbook = excel.application.workbooks.add(1)  set objtempworksheet = objtempworkbook.sheets(1)  'save temp html  set objfilesystem = createobject("scripting.filesystemobject")  strtemphtmlfile = objfilesystem.getspecialfolder(2).path & "\temp excel" & format(now, "yyyy-mm-dd hh-mm-ss") & ".htm"  set objtemphtmlfile = objtempworkbook.publishobjects.add(xlsourcerange, strtemphtmlfile, objtempworksheet.name, objtempworksheet.usedrange.address)  objtemphtmlfile.publish (true) 

so, code, selecting needed excel cells data, copy them, paste them in temporary html file. , here question raises - how continue saying want spread data specific table rows in word file. have not worked integrated vba options word. please assist in?

your start isn't best 1 possible. please try continue on path set following code.

sub vse()      ' word declarations:     dim wdapp word.application     dim doc word.document      ' excel declartions:     dim fn string     dim rngs range                           ' source     dim arr variant      ' in future may specify range more elegantly.     ' so, declare range can later specify in way like:     set rngs = selection     arr = rngs.value      fn = "c:\my documents\testdoc.docx"     set wdapp = new word.application     set doc = wdapp.documents.open(fn) end sub 

the idea start in excel, work in excel, , let excel fidgeting in word. therefore need have access ms word dll. excel's vbe select tools -> references , enable "microsoft word xx.x object library". can declare both word , excel objects. excel presume excel default. therefore mention word in declaration if mean word.

the first objects declare word application, , document run in application. need file name document wish open. after have file name can open document (and perhaps make there, invisible in background without ever showing face, except want see it).

you need data out of excel in transportable format, meaning array. so, declare excel range want copy , write value of range array have declared.

presuming have table in word document might start writing data array table. not clear if have table or want start making @ point.

an alternative copy excel selection , paste word document table. infrastructure these actions same, i.e. 1 sketched above, except wouldn't need array if want paste table. let me warn pasting excel tables word gives lot of headache transferring incompatible formats. pasting excel table word either requires expert @ table formatting or insensitive finer points of document appearance.

anyway, hope gets started in right direction.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -