Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Murray
Here's some automation code that opens a Word Application and Document (Set in the code to C:\Test.doc, but could be any word file, even user selected). It then copies the selected cells in Excel and pastes them to the Word Document at the cursor position, saves the word document as test1.doc (Again, could be anything, cell value, date, user selected), closes the document and Excel, releasing the variables used to hold them. It's only a start and needs much refining Important: The code uses early binding and therefore you will need, in your Excel document to open the VBE(Alt+F11), (This is where the code goes) and go to ToolsReferences and check the box next to Microsoft Word xx Library, where xx is your version. Sub ExportSelectionToWord() Dim wd As New Word.Application Dim doc As New Word.Document Dim rng As Range Set wd = New Word.Application Set doc = wd.Documents.Open(Filename:="C:\Test.doc") wd.Visible = True Set rng = Selection rng.Copy wd.Selection.Paste With doc .SaveAs ("C:\Test1.doc") .Close End With Set doc = Nothing wd.Quit Set wd = Nothing End Sub -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "Murray" wrote in message ... Hi all, I work with Spreadsheets almost daily and evertime I finish one I export certain cells to word. I do this by cutting from Excel and pasting in Word. i can not use the linked spreadsheet because the word document is usually sent to the client as an offer. I was hoping someone could either show me some code to export automatically from Excel to word or a good site to see if I can learn how it is done. Thanks in advance Murray |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Exporting graphs to Word | Excel Discussion (Misc queries) | |||
Exporting information to a word doc | Excel Discussion (Misc queries) | |||
Exporting to Word in a csv file | Excel Discussion (Misc queries) | |||
exporting excel worksheet to word | Links and Linking in Excel | |||
Exporting to Word | Excel Programming |