Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
How do I export a cells contents to a specific word file as a new line? I also want to be able to label each line with a counter. Say for example my cells value is "cell value" and my word file is "destination.doc" I want to be able to do something like counter = 1 Do until activecell.value = empty {"destination.doc" value = counter & activecell.value} {new line so that next string isnt added to end of prev string in word doc} activecell.offset(1,0).select Loop Any ideas? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe something like this. Assumes word doc already exists. You will
need to add a reference to the Microsoft Word Object Library. Copies data from column A in activesheet. Sub AddData() Dim wordApp As Word.Application Dim wordDoc As Word.Document Dim wordRng As Word.Range Dim cell As Range Dim ColA As Range Dim counter As Long Set ColA = ActiveSheet.Range(Cells(1, 1), _ Cells(Cells(Rows.Count, 1).End(xlUp).Row, 1)) counter = 1 Set wordApp = CreateObject("Word.Application") With wordApp .WindowState = wdWindowStateMaximize .Documents.Open ("c:\Temp\destination.doc") 'change as required Set wordDoc = wordApp.ActiveDocument Set wordRng = wordDoc.Range With wordRng For Each cell In ColA .InsertAfter counter & " " & cell.Value .InsertParagraphAfter counter = counter + 1 Next cell End With .ActiveDocument.Save .Quit End With Set wordRng = Nothing Set wordDoc = Nothing Set wordApp = Nothing End Sub Hope this helps Rowan kaiser wrote: Hello, How do I export a cells contents to a specific word file as a new line? I also want to be able to label each line with a counter. Say for example my cells value is "cell value" and my word file is "destination.doc" I want to be able to do something like counter = 1 Do until activecell.value = empty {"destination.doc" value = counter & activecell.value} {new line so that next string isnt added to end of prev string in word doc} activecell.offset(1,0).select Loop Any ideas? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Rowan...gives me the base that I need
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Show contents of Word document in cell | Excel Discussion (Misc queries) | |||
Exporting multiple cell contents into word document | Excel Worksheet Functions | |||
Help, insert a word document contents into excel tab? | Excel Discussion (Misc queries) | |||
Exporting VBA DataForm Info to Word document | Excel Programming | |||
Exporting text to a Word document | Excel Programming |