Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents | Excel Discussion (Misc queries) | |||
combining word documents and excel worksheets | Excel Discussion (Misc queries) | |||
Field missing on completed mail merge Excel - Word once merged | Excel Discussion (Misc queries) | |||
Create merged mail in Excel (*NOT* in Word)? | Excel Discussion (Misc queries) | |||
how do I use mail merge in excel for word documents | Excel Discussion (Misc queries) |