Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Exporting to Word

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
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
Exporting graphs to Word kippers Excel Discussion (Misc queries) 3 April 9th 09 01:34 PM
Exporting information to a word doc Exporting information to a word doc Excel Discussion (Misc queries) 1 January 14th 09 04:03 PM
Exporting to Word in a csv file Brad Excel Discussion (Misc queries) 5 August 20th 05 06:53 PM
exporting excel worksheet to word morrowkd Links and Linking in Excel 1 May 6th 05 12:16 PM
Exporting to Word Debra Dalgleish[_2_] Excel Programming 0 September 25th 03 01:36 PM


All times are GMT +1. The time now is 12:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"