Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
La La is offline
external usenet poster
 
Posts: 10
Default multiple worksheets in workbook mail merged into a word documents

I'm not sure if this is possible since I'm new at this. Trying to print
labels, letters in word with the data source being a excel document with
multiple sheets contained in it with the information that I need. Is this
possible? Is it difficult to do?

Thanks.
Al
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default multiple worksheets in workbook mail merged into a word documents

Try this sub:

Sub CopyWorksheetsToWord()
' requires a reference to the Word Object library:
' in the VBE select Tools, References and check the Microsoft Word X.X
object library
Dim wdApp As Word.Application, wdDoc As Word.Document, ws As Worksheet
Application.ScreenUpdating = False
Application.StatusBar = "Creating new document..."
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Add
For Each ws In ActiveWorkbook.Worksheets
Application.StatusBar = "Copying data from " & ws.Name & "..."
ws.UsedRange.Copy ' or edit to the range you want to copy
wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.Ins ertParagraphAfter
wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.Pas te
Application.CutCopyMode = False
wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.Ins ertParagraphAfter
' insert page break after all worksheets except the last one
If Not ws.Name = Worksheets(Worksheets.Count).Name Then
With wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range
.InsertParagraphBefore
.Collapse Direction:=wdCollapseEnd
.InsertBreak Type:=wdPageBreak
End With
End If
Next ws
Set ws = Nothing
Application.StatusBar = "Cleaning up..."
' apply normal view
With wdApp.ActiveWindow
If .View.SplitSpecial = wdPaneNone Then
.ActivePane.View.Type = wdNormalView
Else
.View.Type = wdNormalView
End If
End With
Set wdDoc = Nothing
wdApp.Visible = True
Set wdApp = Nothing
Application.StatusBar = False
End Sub

Not sure who the author is, so I can't give credit even though it is due for
this...



Regards,
Ryan---

"la" wrote:

I'm not sure if this is possible since I'm new at this. Trying to print
labels, letters in word with the data source being a excel document with
multiple sheets contained in it with the information that I need. Is this
possible? Is it difficult to do?

Thanks.
Al

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
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents BenS Excel Discussion (Misc queries) 3 June 29th 07 12:20 AM
combining word documents and excel worksheets akcaster Excel Discussion (Misc queries) 1 June 10th 06 01:59 AM
Field missing on completed mail merge Excel - Word once merged Baffled PA Excel Discussion (Misc queries) 0 February 15th 06 01:21 PM
Create merged mail in Excel (*NOT* in Word)? DolfnJudy Excel Discussion (Misc queries) 0 November 8th 05 01:36 PM
how do I use mail merge in excel for word documents Lisa J Duffy Excel Discussion (Misc queries) 1 August 4th 05 01:40 PM


All times are GMT +1. The time now is 03:32 AM.

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"