Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export excel data to word document mda19652 Excel Discussion (Misc queries) 1 November 1st 07 12:01 PM
Export excel data to create report in Word jbrzez Excel Discussion (Misc queries) 2 January 30th 07 02:21 PM
Can Excel Export Data to Word Format? Reddiance Excel Discussion (Misc queries) 2 April 18th 05 06:03 PM
export excel data to a word template using a macro Ross1 Excel Programming 1 March 25th 05 04:31 AM
export/import excel data to word doc. properties William Excel Programming 0 September 21st 04 08:41 PM


All times are GMT +1. The time now is 03:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"