ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Import filtered data into a word document (https://www.excelbanter.com/excel-discussion-misc-queries/221817-import-filtered-data-into-word-document.html)

Obonden

Import filtered data into a word document
 
Is it possible to make a word-report from excel, where the data is divided
in groups based on different criterias?

An example, where towns starting on S i chosen first, then towns on O next:

Wordtext text text ....

Stockholm, Sweden
Sevilla, Spain
Sandefjord, Norway

More text, more text, more text ....

Oslo, Norway
Ohio, USA

And so on... - or are there any other solution on presenting multiple-sorted
data?



curlydave

Import filtered data into a word document
 
This code when run from Excel will copy your filtered data from Excel
and paste it into a specific Word Doc. Be careful where your cursor is
in the doc as it will paste where the cursor is.

Sub CopyFilteredDataToWord()

Dim wdApp As Word.Application, wdDoc As Word.Document

On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number < 0 Then 'Word isn't already running
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
Set wdDoc = wdApp.Documents.Open("C:\Excel Forums
\LinkedToWord.doc") 'change the location and Doc Name
wdApp.Visible = True
Sheet2.AutoFilter.Range.Copy 'change sheet name of filtered data
wdApp.Selection.Paste
Application.CutCopyMode = False
End Sub





All times are GMT +1. The time now is 08:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com