ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting a range from Excel into a Word document (https://www.excelbanter.com/excel-programming/291173-getting-range-excel-into-word-document.html)

daniB[_6_]

Getting a range from Excel into a Word document
 
Hello All,

I am trying to get a named range into a word document.....I have thi
code....

It creates a word document correctly with the right path however, ho
do i get the named range into the word document??

Any Ideas??

Thanks - Dani

Sub MakeWordFile()
' Creates Word document
Dim WordApp As Object

On Error Resume Next
Application.ScreenUpdating = False

' Start Word and create an object
Set WordApp = CreateObject("Word.Application")
With WordApp
.Documents.Add
End With

' Determine the file name
SaveAsName = ThisWorkbook.Path & "\" & "volumeslast2weeks.doc"

' Select worksheet
Sheets("NETWORKS").Select




' Information from worksheet
Set Data = Sheets("Networks").Range("Changes")






' Send commands to Word
With WordApp
With .Selection
'?????SOMETHING TO GO HERE TO IMPUT THE DATA IN RANG
"Changes" or Variable Set Data????

End With
End With

' Save the Word file and close it
With WordApp
.ActiveDocument.SaveAs Filename:=SaveAsName
.ActiveWindow.Close
' Kill the object
.Quit
End With

Set WordApp = Nothing

' Reset status bar
Application.StatusBar = ""
MsgBox "Completed and saved " & ThisWorkbook.Path
End Su

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 11:21 AM.

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