Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default paste to word document and save


I want to copy a section of an excel sheet to a word document and save
the word document. I have tried several senarios to no avail. My
attempts do not recognize that the word document exists.

What code do I use and do I need to do something special so that the
excel workbook cooperates with word?

Thank you,

David


--
eyecalibrate
------------------------------------------------------------------------
eyecalibrate's Profile: http://www.excelforum.com/member.php...fo&userid=6621
View this thread: http://www.excelforum.com/showthread...hreadid=497181

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default paste to word document and save

Something like this:

Sub PrintToWordFile()


Const fname = "C:\Test.doc"
Const rname = "A1:B10"


Dim a As Excel.Range
Dim g As Boolean
Dim o As Object
Dim w As Word.Document
Dim wdRng as Word.Range

g = ActiveWindow.DisplayGridlines
ActiveWindow.DisplayGridlines = False
Set a = Range(rname)
a.Copy


set o = CreateObject("Word.Application")
' or if word is open
' GetObject(, "Word.Application")

With o
.Visible = True
.Documents.Open Filename:=fname, ReadOnly:=False
Set w = .Documents(fname)
set wdRng = selection
End With


'*****


' PASTE TABLE
WdRng.PasteSpecial Link:=False, _
DataType:=1, Placement:=0, _
DisplayAsIcon:=False
'' 1 = wdPasteRTF, 0 = wdInLine


'*****


w.SaveAs "C:\Test.doc"
o.Application.Quit


ActiveWindow.DisplayGridlines = g
Set w = Nothing
Set o = Nothing
End Sub


--
Regards,
Tom Ogilvy

"eyecalibrate"
wrote in message
news:eyecalibrate.20x41b_1136055002.9873@excelforu m-nospam.com...

I want to copy a section of an excel sheet to a word document and save
the word document. I have tried several senarios to no avail. My
attempts do not recognize that the word document exists.

What code do I use and do I need to do something special so that the
excel workbook cooperates with word?

Thank you,

David


--
eyecalibrate
------------------------------------------------------------------------
eyecalibrate's Profile:

http://www.excelforum.com/member.php...fo&userid=6621
View this thread: http://www.excelforum.com/showthread...hreadid=497181



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
PASTE LINK option not available when I select PASTE SPECIAL to link an image in Excel to a Word document. tln Links and Linking in Excel 0 April 22nd 07 04:28 PM
Can you save an excel spreadsheet to a word document or pdf? Gen Excel Discussion (Misc queries) 5 April 11th 07 10:04 PM
How do I paste a Word document into an Excel cell callawayx18 Excel Discussion (Misc queries) 0 January 10th 07 10:46 PM
is it possible to save xls file to a word document like an attachm weit Excel Discussion (Misc queries) 2 February 22nd 06 06:57 PM
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM


All times are GMT +1. The time now is 02:15 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"