LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default writing excel data into word document

I want to create report in Word using data from excel. I have problems with writing several paragraphs, one after the other, starting after bookmark created in word templates. In my code it is writing in reverse order and I would like to change it. In addition I would like to add paragraph styles after inserting each paragraph. How I should change my code ?

Thanks for help / suggestions.

Sub CreateWordReport()

Dim applWord As Object

TodaysDate = Format(Date, "dd mmm, yyyy")

'Create a new instance of the Word application, if an existing Word object is not available.
'Set the Application object as follows:
On Error Resume Next
Set applWord = GetObject(, "Word.Application")
'if an instance of an existing Word object is not available, an error will occur (Err.Number = 0 means no error):
If Err.Number < 0 Then
Set applWord = CreateObject("Word.Application")
End If
'disable error handling:
On Error GoTo 0

'make the Word window visible:
applWord.Visible = True

'add a new word document:
applWord.Documents.add Template:="G:\Template\RTS Flash - Template.dotx", _
NewTemplate:=False, DocumentType:=0

'to save document in the default folder:
NewFileName = "c:\temp\Flash Report " & TodaysDate & ".docx"
applWord.ActiveDocument.SaveAs Filename:=NewFileName

With ActiveDocument
.Bookmarks("MajorIssuesStart").Range.InsertAfter "Inserted Text"
.Bookmarks("MajorIssuesStart").Range.InsertAfter Chr(13)
.Bookmarks("MajorIssuesStart").Range.InsertAfter "Second Inserted Text"
.Bookmarks("MajorIssuesStart").Range.InsertAfter Chr(13)
.Bookmarks("MajorIssuesStart").Range.InsertAfter "Third Inserted Text"
End With

'clear the object variables:
Set applWord = Nothing

End Sub
 
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
Linking excel data to a word document Hutchy Excel Discussion (Misc queries) 0 May 16th 07 08:46 AM
Transferring Excel Data to Word Document maacmaac Excel Programming 1 October 7th 05 07:38 AM
Transferring Excel Data to Word Document maacmaac Excel Discussion (Misc queries) 0 October 6th 05 05:23 PM
Creating a Word Document from Excel Data Sheldon Excel Programming 1 September 15th 04 10:10 PM


All times are GMT +1. The time now is 01:58 AM.

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

About Us

"It's about Microsoft Excel"