Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Export data to from Excel to Word
I have an Excel worksheet with columns of data that was filled in by a Macro.
I would like to extract one column of that data and paste it into a Word document with a Macro. I have tried using answers to other questions but they don't quite make it work. Help? Jim |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Export data to from Excel to Word
Jim- I'll provide sample code here (and hopefully it will help); If you can't
get it working, I'd suggest re-posting and indicating what version of Excel and Word you are using, and where you are getting stuck- is Word not opening? Is Word open, but your desired contents aren't getting pasted in properly? etc. This code should give you a basic starting point; you will still need to use VBA to cycle through your target column's values to add them to Word instead of using the WER array. My apologies to whomever originally posted this code- I didn't capture that way back (mid 90's?) when I first acquired this snippet. Best, Keith Sub createDoc() Dim wordApp As Word.Application Dim wordDoc As Word.Document Dim wordRng As Word.Range Dim wordPara As Word.Paragraph Dim WER(1 To 3) As Variant Set wordApp = CreateObject("Word.Application") With wordApp .WindowState = wdWindowStateMaximize .Documents.Add Set wordDoc = wordApp.ActiveDocument Set wordRng = wordDoc.Range With wordRng WER(1) = "tree" WER(2) = "bed" WER(3) = "car" .InsertAfter WER(1) .InsertParagraphAfter .InsertAfter WER(2) .InsertParagraphAfter .InsertAfter WER(3) .InsertParagraphAfter ' insert a blank paragraph between the two paragraphs .InsertParagraphAfter End With Set wordPara = wordRng.Paragraphs(3) With wordPara.Range .Bold = True .Italic = False .Font.Size = 12 .InsertAfter "Report Created: " .Collapse Direction:=wdCollapseEnd .InsertDateTime DateTimeFormat:="MM-DD-YY HH:MM:SS" End With .ActiveDocument.saveas "c:\Test_Create_Doc.Doc" .Quit End With Set wordPara = Nothing Set wordRng = Nothing Set wordDoc = Nothing Set wordApp = Nothing End Sub "jswalsh33" wrote: I have an Excel worksheet with columns of data that was filled in by a Macro. I would like to extract one column of that data and paste it into a Word document with a Macro. I have tried using answers to other questions but they don't quite make it work. Help? Jim |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Export excel data to word document | Excel Discussion (Misc queries) | |||
Export excel data to create report in Word | Excel Discussion (Misc queries) | |||
Can Excel Export Data to Word Format? | Excel Discussion (Misc queries) | |||
export excel data to a word template using a macro | Excel Programming | |||
export/import excel data to word doc. properties | Excel Programming |